Prechádzať zdrojové kódy

清理废弃的控制器文件

liuhairui 2 týždňov pred
rodič
commit
9a0858a09c

+ 0 - 1364
application/api/controller/FinishedProductWarehousing.php

@@ -1,1364 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-
-/**
- * 成品入仓维护接口
- */
-class FinishedProductWarehousing extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *成品入仓测试
-     */
-    public function index()
-    {   
-        $this->success('请求成功');
-    }
-
-    /**
-     * 侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $rows = db('成品入仓')
-            ->field('LEFT(Sys_rq, 10) as date, COUNT(*) as counts')
-            ->group('date')
-            ->order('UniqId desc')
-            ->limit(50)
-            ->select();
-
-        $num = db('成品入仓')
-            ->where('Sys_rq','>=',$rows[count($rows)-1]['date'])
-            ->count();
-        $arr = db('成品入仓')
-            ->field('LEFT(Sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(*) as count')
-            ->where('Sys_rq','>=',$rows[count($rows)-1]['date'])
-            ->group('date, sys_id')
-            ->limit($num)
-            ->select();
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['sys'] = [];
-            foreach($arr as $k=>$v){
-                if($value['date'] == $v['date']){
-                    unset($v['date']);
-                    array_push($rows[$key]['sys'],$v);
-                    unset($arr[$k]);
-                }
-            }
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
-        }
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTabByGdbh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-
-        $num = db('成品入仓')->count();
-        $rows = db('成品入仓')
-            ->field('jjcp_gdbh, rtrim(jjcp_cpdh) as jjcp_cpdh, LEFT(Sys_rq, 10) as Sys_rq')
-            ->order('Sys_rq desc')
-            ->limit($num)
-            ->select();
-
-        $num = db('工单_基本资料')->count();
-        $arr = db('工单_基本资料')
-            ->limit($num)
-            ->column('CONCAT(Gd_gdbh, "-", rtrim(Gd_cpdh)) AS gdcp, CONCAT(rtrim(Gd_khdh), " 【", rtrim(Gd_khmc)) AS kh');
-
-        $data = [];
-        foreach ($rows as $value) {
-            $key = $value['jjcp_gdbh'].'-'.$value['jjcp_cpdh'];
-            if (isset($arr[$key]) && !isset($data[$arr[$key]])) {
-                $data[$arr[$key]] = $value['Sys_rq'];
-            }
-        }
-        // 对键进行升序排序
-        uksort($data, function($a, $b) use ($data) {
-            if ($data[$a] == $data[$b]) {
-                return ($a > $b) ? 1 : -1; // 在值相同的情况下,根据键进行升序排列
-            }
-            return ($data[$a] < $data[$b]) ? 1 : -1;
-        });
-
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (!isset($req['date'])) $this->error('参数缺失');
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        if(strpos($req['date'],'-')){
-            $where = ['c.Sys_rq'=>['like',$req['date'].'%']];
-            $option = ['Sys_rq'=>['like',$req['date'].'%']];
-        }else{
-            $where = [];
-            $option = [];
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])){
-            $where['c.Sys_id'] = ['LIKE',$req['sys_id'].'%'];
-            $option['Sys_id'] = ['LIKE',$req['sys_id'].'%'];
-        }
-        //客户编号
-        $rows = db('成品入仓')->alias('c')
-            ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称, 
-            rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh, 
-            c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj, 
-            rtrim(c.jjcp_smb) as jjcp_smb, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称, 
-            rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称, 
-            rtrim(c.机型备注) as 机型备注, rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
-            ->where($where)
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->order('c.UniqId desc')
-            ->page($page,$limit)
-            ->select();
-
-        $total = db('成品入仓')->where($option)->count();
-        foreach ($rows as $key=>$value) {
-            $row = db('成品入仓')
-                ->field('LEFT(Sys_rq, 10) as Sys_rq,jjcp_sl')
-                ->where(['jjcp_gdbh'=>$value['jjcp_gdbh'], 'jjcp_cpdh'=>$value['jjcp_cpdh']])
-                ->order('Sys_rq desc')
-                ->select();
-            $rows[$key]['jjcp_sls'] = 0;
-            foreach ($row as $k=>$v) {
-                $rows[$key]['jjcp_sls'] += $v['jjcp_sl'];
-            }
-            if ($value['订单数量']!=0){
-                $rows[$key]['完成率'] = number_format($rows[$key]['jjcp_sls']/$value['订单数量']/100,2);
-            }else{
-                $rows[$key]['完成率'] = '';
-            }
-            $rows[$key]['订单数量'] = floatval($value['订单数量']*10000);
-            $rows[$key]['最近入仓日期'] = $row[0]['Sys_rq'];
-
-            $rows[$key]['Mod_rq'] = $value['Mod_rq']=='1900-01-01 00:00:00' ? '' :$value['Mod_rq'];
-        }
-
-        $data = [
-            'total'          => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 定位
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $cpmc 产品名称
-     * @param string $page 页码
-     * @param string $limit 数量
-     */
-    public function locate()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $where = ['c.jjcp_gdbh'=>[ 'like', '%' . $req['gdbh'] . '%']];
-            $option = ['jjcp_gdbh'=>[ 'like', '%' . $req['gdbh'] . '%']];
-            //客户编号
-            $rows = db('成品入仓')->alias('c')
-                ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称, 
-            rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh, 
-            c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj, 
-            rtrim(c.jjcp_smb) as jjcp_smb, rtrim(y.yj_Yjdh) as yj_Yjdh, rtrim(y.yj_yjmc) as yj_yjmc, 
-            rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称, 
-            rtrim(c.机型备注) as 机型备注, rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
-                ->where($where)
-                ->where('y.yj_Yjno=c.jjcp_yjno')
-                ->where('g.Gd_cpdh=c.jjcp_cpdh')
-                ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-                ->join('工单_印件资料 y','y.Yj_Gdbh=c.jjcp_gdbh')
-                ->order('c.UniqId desc')
-                ->page($page,$limit)
-                ->select();
-            $total = db('成品入仓')->where($option)->count();
-        }else{
-            if (isset($req['cpmc']) && !empty($req['cpmc'])){
-                //查询工单表
-                $gd = db('工单_基本资料')
-                    ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
-                    ->column('Gd_gdbh');
-                $where = ['c.jjcp_gdbh'=>['in', $gd]];
-                $option = ['jjcp_gdbh'=>['in', $gd]];
-                //客户编号
-                $rows = db('成品入仓')->alias('c')
-                    ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称, 
-            rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh, 
-            c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj, 
-            rtrim(c.jjcp_smb) as jjcp_smb, rtrim(y.yj_Yjdh) as yj_Yjdh, rtrim(y.yj_yjmc) as yj_yjmc, 
-            rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称, 
-            rtrim(c.机型备注) as 机型备注, rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
-                    ->where($where)
-                    ->where('y.yj_Yjno=c.jjcp_yjno')
-                    ->where('g.Gd_cpdh=c.jjcp_cpdh')
-                    ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-                    ->join('工单_印件资料 y','y.Yj_Gdbh=c.jjcp_gdbh')
-                    ->order('c.UniqId desc')
-                    ->page($page,$limit)
-                    ->select();
-                $total = db('成品入仓')->where($option)->count();
-            }else{
-                $this->error('参数错误');
-            }
-        }
-        foreach ($rows as $key=>$value) {
-            $row = db('成品入仓')
-                ->field('LEFT(Sys_rq, 10) as Sys_rq,jjcp_sl')
-                ->where(['jjcp_gdbh'=>$value['jjcp_gdbh'], 'jjcp_cpdh'=>$value['jjcp_cpdh']])
-                ->order('Sys_rq desc')
-                ->select();
-            $rows[$key]['jjcp_sls'] = 0;
-            foreach ($row as $k=>$v) {
-                $rows[$key]['jjcp_sls'] += $v['jjcp_sl'];
-            }
-            if ($value['订单数量']!=0){
-                $rows[$key]['完成率'] = number_format($rows[$key]['jjcp_sls']/$value['订单数量']/100,2);
-            }else{
-                $rows[$key]['完成率'] = '';
-            }
-            $rows[$key]['订单数量'] = floatval($value['订单数量']*10000);
-            $rows[$key]['最近入仓日期'] = $row[0]['Sys_rq'];
-
-            $rows[$key]['Mod_rq'] = $value['Mod_rq']=='1900-01-01 00:00:00' ? '' :$value['Mod_rq'];
-        }
-        $data = [
-            'total'    => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-        //客户编号
-        $rows = db('成品入仓')->alias('c')
-            ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称, 
-            rtrim(c.jjcp_num) as jjcp_num, 
-            c.jjcp_gdbh, c.jjcp_yjno, rtrim(c.订单编号) as 订单编号, 
-            rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称, 
-            rtrim(c.客户料号) as 客户料号, 
-            rtrim(c.jjcp_smb) as jjcp_smb, LEFT(c.jjcp_sj, 10) as jjcp_sj, 
-            c.jjcp_sl, rtrim(c.jjcp_dw) as jjcp_dw, 
-            g.订单数量*10000 as 订单数量, rtrim(c.机型备注) as 机型备注, rtrim(c.jjcp_desc) as jjcp_desc, 
-            rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
-            ->where('c.UniqId',$UniqId)
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->find();
-
-        $rows['jjcp_sls'] = db('成品入仓')
-            ->where(['jjcp_gdbh'=>$rows['jjcp_gdbh'], 'jjcp_cpdh'=>$rows['jjcp_cpdh']])
-            ->sum('jjcp_sl');
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取仓库信息
-     * @ApiMethod (GET)
-     * @param string keyword 关键词
-     */
-    public function getCk()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $key_word = '';
-        if (isset($req['key_word']) && !empty($req['key_word'])){
-            $key_word = $req['key_word'];
-        }
-        $rs = db('物料_仓库信息')
-            ->field('rtrim(编号) as 编号, rtrim(名称) as 名称')
-            ->where('编号|名称','like','%'.$key_word.'%')
-            ->where('名称','in',['面材仓库','主要产成品'])
-            ->select();
-
-        $this->success('成功',$rs);
-    }
-
-    /**
-     * 查询印件工序及产品名称
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     */
-    public function getGd()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db('工单_基本资料')->alias('g')
-            ->field('g.Gd_gdbh, j.yj_yjno, rtrim(g.销售订单号) as 销售订单号, rtrim(j.yj_Yjdh) as yj_Yjdh, rtrim(j.yj_yjmc) as yj_yjmc, rtrim(g.成品代号) as 成品代号, rtrim(g.成品名称) as 成品名称, rtrim(g.客户料号) as 客户料号')
-            ->where(['g.Gd_gdbh'=>$gdbh])
-            ->join(['工单_印件资料'=>'j'],'g.Gd_cpdh=j.yj_yjdh and g.Gd_gdbh=j.Yj_Gdbh')
-            ->group('j.yj_yjno')
-            ->order('j.yj_yjno asc')
-            ->select();
-        // $rows = db()->table('工单_印件资料')->alias('j')
-        //     ->field('g.Gd_gdbh, j.yj_Yjno as yj_yjno, rtrim(g.销售订单号) as 销售订单号, rtrim(j.yj_Yjdh) as yj_Yjdh, 
-        //     rtrim(j.yj_yjmc) as yj_yjmc, rtrim(g.成品代号) as 成品代号, rtrim(g.成品名称) as 成品名称, rtrim(g.客户料号) as 客户料号')
-        //     ->where(['g.Gd_gdbh'=>$gdbh])
-        //     ->join(['工单_基本资料'=>'g'],'g.Gd_gdbh=j.Yj_Gdbh')
-        //     ->select();
-
-        foreach ($rows as $key=>$value){
-            $rows[$key]['gdyj'] =  $value['Gd_gdbh'].' -'.sprintf("%02d", $value['yj_yjno']).'-'.$value['yj_yjmc'];
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询工单数量
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $cpdh 产品代号
-     * @param string $rcsl 入仓数量
-     */
-    public function getGdsl()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['cpdh']) && !empty($req['cpdh'])){
-            $cpdh = $req['cpdh'];
-        }else{
-            $this->error('参数错误');
-        }
-//        if (isset($req['rcsl'])){
-//            $rcsl = $req['rcsl'];
-//        }else{
-//            $this->error('参数错误');
-//        }
-
-        $rows = db('工单_基本资料')->alias('g')
-            ->field('订单数量*10000 as 订单数量, gd_statu')
-            ->where(['Gd_gdbh'=>$gdbh, 'Gd_cpdh'=>$cpdh])
-            ->find();
-
-        if (!$rows) $this->error('未查询到记录');
-
-        $rows['jjcp_sls'] = db('成品入仓')
-            ->where(['jjcp_gdbh'=>$gdbh, 'jjcp_cpdh'=>$cpdh])
-            ->sum('jjcp_sl');
-
-//        if ($rows['订单数量']<($rows['jjcp_sls']+$rcsl) || mb_substr($rows['gd_statu'],-3,3)=='已完工'){
-//            $this->error('已完工或入仓数量超过订单数量',$rows);
-//        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string
-     */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'Sys_id',
-            '入仓类型', '仓库编号', '仓库名称',
-            'jjcp_num',
-            'jjcp_gdbh', 'jjcp_yjno', '订单编号',
-            'jjcp_cpdh', 'jjcp_cpmc',
-            '成品编码', '成品名称',
-            '客户料号',
-            'jjcp_smb', 'jjcp_sj',
-            'jjcp_sl', 'jjcp_dw',
-            '机型备注',
-            'jjcp_desc'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['Sys_rq'] = date('Y-m-d H:i:s');
-
-        //查询UniqId
-        $UniqId = db('成品入仓')->max('UniqId');
-        $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('成品入仓')->fetchSql(true)->insert($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     */
-    public function edit()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            '入仓类型', '仓库编号', '仓库名称',
-            'jjcp_num',
-            'jjcp_gdbh', 'jjcp_yjno', '订单编号',
-            'jjcp_cpdh', 'jjcp_cpmc',
-            '成品编码', '成品名称',
-            '客户料号',
-            'jjcp_smb', 'jjcp_sj',
-            'jjcp_sl', 'jjcp_dw',
-            '机型备注',
-            'jjcp_desc'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                continue;
-            }
-            $data[$value] = $req[$value];
-        }
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-        if (count($data)==0){
-            $this->error('参数错误','',111);
-        }
-        $data['Mod_rq'] = date('Y-m-d H:i:s');
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('成品入仓')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId'
-     */
-    public function del()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db('成品入仓')->where('UniqId',$req['UniqId'])->delete();
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * excel导出
-     * @ApiMethod (POST)
-     * @param string date
-     * @param string sys_id
-     * @param array fields
-     */
-    public function export(){
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!isset($req['date'])) $this->error('参数缺失');
-
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-
-        if(strpos($req['date'],'-')){
-            $where = ['c.Sys_rq'=>['like',$req['date'].'%']];
-        }else if(empty($req['date'])){
-            $where = [];
-        }else{
-            $where = ['c.jjcp_gdbh'=>$req['date']];
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])){
-            $where['c.Sys_id'] = ['LIKE',$req['sys_id'].'%'];
-        }
-
-        $arr = [
-            '入仓类型'      =>['入仓类型'],
-            '仓库编号'      =>['仓库编号'],
-            '仓库名称'      =>['仓库名称'],
-            'jjcp_num'     =>['入仓单号'],
-            'jjcp_gdbh'    =>['工单编号'],
-            'jjcp_yjno'    =>['印件号'],
-            'jjcp_sl'      =>['入仓数量'],
-            'jjcp_sls'     =>['累计入仓数量'],
-            '订单数量'      =>['订单数量'],
-            '完成率'        =>['完成率'],
-            'jjcp_dw'      =>['单位'],
-            'jjcp_sj'      =>['入仓时间'],
-            'jjcp_smb'     =>['首末板'],
-            'jjcp_cpdh'    =>['印件代号'],
-            'jjcp_cpmc'    =>['印件名称'],
-            '成品编码'      =>['产品编号'],
-            '成品名称'      =>['产品名称'],
-            '客户料号'      =>['客户料号'],
-            'jjcp_desc'    =>['备注'],
-            '客户编号'      =>['客户编号'],
-            'Gd_客户名称'   =>['客户名称'],
-            '最近入仓日期'  =>['最近入仓日期'],
-            '机型备注'      =>['机型备注'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        $num = db('成品入仓')->alias('c')
-            ->where($where)
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->count();
-
-        $rows = [];
-        for($i=1;$i<=ceil($num/10000);$i++){
-            $p = $i == ceil($num/10000) ? $num%10000 : 10000;
-            $r = db('成品入仓')->alias('c')
-                ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称, 
-            rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh, 
-            c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj, 
-            rtrim(c.jjcp_smb) as jjcp_smb, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称, 
-            rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称, 
-            rtrim(c.机型备注) as 机型备注')
-                ->where($where)
-                ->where('g.Gd_cpdh=c.jjcp_cpdh')
-                ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-                ->order('c.UniqId desc')
-                ->limit($i,$p)
-                ->select();
-            $rows = array_merge($rows,$r);
-        }
-
-        foreach ($rows as $key=>$value) {
-            $row = db('成品入仓')
-                ->field('LEFT(Sys_rq, 10) as Sys_rq,jjcp_sl')
-                ->where(['jjcp_gdbh'=>$value['jjcp_gdbh'], 'jjcp_cpdh'=>$value['jjcp_cpdh']])
-                ->order('Sys_rq desc')
-                ->select();
-
-            $subArray = [];
-            foreach ($arr as $k=>$v){
-                if($k=='jjcp_sls'){
-                    $subArray[$k] = 0;
-                    foreach ($row as $n) {
-                        $subArray[$k] += $n['jjcp_sl'];
-                    }
-                }else if($k=='完成率'){
-                    if ($value['订单数量']!=0){
-                        $subArray[$k] = 0;
-                        foreach ($row as $n) {
-                            $subArray[$k] += $n['jjcp_sl'];
-                        }
-                        $subArray[$k] = number_format($subArray[$k]/$value['订单数量']/100,2);
-                    }else{
-                        $subArray[$k] = '';
-                    }
-                }else if($k=='最近入仓日期'){
-                    $subArray[$k] = $row[0]['Sys_rq'];
-                }else{
-                    $subArray[$k] = $rows[$key][$k];
-                }
-            }
-            array_push($data,$subArray);
-        }
-
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-
-    /**
-     * 月度A
-     * @ApiMethod (POST)
-     * @param string start_time
-     * @param string end_time
-     * @param string file_name
-     * @param array fields
-     */
-    public function monthExportA(){
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'start_time', 'end_time', 'file_name'
-        ];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-        }
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-
-        $arr = [
-            '入仓类型'      =>['入仓类型'],
-            '仓库编号'      =>['仓库编号'],
-            '仓库名称'      =>['仓库名称'],
-            'jjcp_gdbh'    =>['工单编号'],
-            'jjcp_cpdh'    =>['入仓存货编号'],
-            'jjcp_cpmc'    =>['入仓存货名称'],
-            'jjcp_sl'      =>['入仓数量'],
-            'jjcp_dw'      =>['单位'],
-            'jjcp_sj'      =>['入仓时间'],
-            'jjcp_smb'     =>['首末板'],
-            'jjcp_num'     =>['单据编号'],
-            '订单编号'      =>['订单编号'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        //客户编号
-        $rows = db('成品入仓')->alias('c')
-            ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称, 
-            c.jjcp_gdbh, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            c.jjcp_sl, rtrim(c.jjcp_dw) as jjcp_dw, c.jjcp_sj, 
-            rtrim(c.jjcp_smb) as jjcp_smb, 
-            rtrim(c.jjcp_num) as jjcp_num, rtrim(c.订单编号) as 订单编号
-            ')
-            ->where('c.jjcp_sj','between time',[$req['start_time'], $req['end_time']])
-            ->order('c.jjcp_sj asc')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->select();
-
-        foreach ($rows as $key=>$value) {
-            $subArray = [];
-            foreach ($arr as $k=>$v){
-                $subArray[$k] = $rows[$key][$k];
-            }
-            array_push($data,$subArray);
-        }
-
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-
-    /**
-     * 月度B
-     * @ApiMethod (POST)
-     * @param string start_time
-     * @param string end_time
-     * @param string file_name
-     * @param array fields
-     */
-    public function monthExportB(){
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'start_time', 'end_time', 'file_name'
-        ];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-        }
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-
-        $arr = [
-            '入仓类型'      =>['入仓类型'],
-            '客户编号'      =>['客户编号'],
-            '客户名称'      =>['客户名称'],
-            '产品类别'      =>['产品类别'],
-            'jjcp_gdbh'    =>['工单编号'],
-            '成品编码'      =>['成品编码'],
-            '成品名称'      =>['成品名称'],
-            'jjcp_sls'     =>['入仓数量'],
-            '大箱产量'      =>['大箱产量'],
-            '产品单价'      =>['万张单价'],
-            '产值万元'      =>['产值万元'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        $rows1 = db('成品入仓')->alias('c')
-            ->field('rtrim(c.入仓类型) as 入仓类型, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(b.客户名称) as 客户名称,
-            rtrim(b.产品类别) as 产品类别, c.jjcp_gdbh,
-            rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称
-            ')
-            ->where('c.jjcp_sj','between time',[$req['start_time'], $req['end_time']])
-            ->order('客户编号 asc,b.产品类别 desc,c.成品编码 asc,c.jjcp_gdbh asc')
-            ->join('产品_基本资料 b','b.产品编号=c.jjcp_cpdh')
-            ->group('c.jjcp_gdbh')
-            ->select();
-
-        $rows2 = db('成品入仓')
-            ->field('rtrim(入仓类型) as 入仓类型, rtrim(成品编码) as 客户编号, 
-            rtrim(成品编码) as 客户名称, rtrim(成品编码) as 产品类别,
-            jjcp_gdbh,rtrim(成品编码) as 成品编码, rtrim(成品名称) as 成品名称
-            ')
-            ->where('jjcp_sj','between time',[$req['start_time'], $req['end_time']])
-            ->where('成品编码','')
-            ->order('jjcp_gdbh asc')
-            ->group('jjcp_gdbh')
-            ->select();
-        $rows = array_merge($rows2,$rows1);
-
-        $num = db('工单_基本资料')->count();
-        $arr1 = db('工单_基本资料')->limit($num)
-            ->column('CONCAT(Gd_gdbh, "-", rtrim(Gd_cpdh)) AS gdcp, 产品单价 as 万张单价');
-
-        $brr = array_column($rows,'jjcp_gdbh');
-        $brr = db('成品入仓')
-            ->where('jjcp_gdbh', 'in', $brr)
-            ->group('jjcp_gdbh')
-            ->column('jjcp_gdbh, sum(jjcp_sl)');
-
-        foreach ($rows as $key=>$value) {
-            $subArray = [];
-            foreach ($arr as $k=>$v){
-                if($k=='jjcp_sls'){
-                    $subArray[$k] = $brr[$value['jjcp_gdbh']];
-                }else if ($k=='大箱产量'){
-                    if($value['产品类别']=='条盒'){
-                        $subArray[$k] = $brr[$value['jjcp_gdbh']]/250;
-                    }else if($value['产品类别']=='小盒'){
-                        $subArray[$k] = $brr[$value['jjcp_gdbh']]/2500;
-                    }else{
-                        $subArray[$k] = 0;
-                    }
-                }else if ($k=='产品单价'){
-                    if($value['产品类别']!=''){
-                        if (array_key_exists($value['jjcp_gdbh'].'-'.$value['成品编码'],$arr1)){
-                            $subArray[$k] = floatval(number_format($arr1[$value['jjcp_gdbh'].'-'.$value['成品编码']],4));
-                        }
-                    }else{
-                        $subArray[$k] = 0;
-                    }
-                }else if ($k=='产值万元'){
-                    if($value['产品类别']!=''){
-                        if (array_key_exists($value['jjcp_gdbh'].'-'.$value['成品编码'],$arr1)){
-                            $subArray[$k] = floatval(number_format($arr1[$value['jjcp_gdbh'].'-'.$value['成品编码']]*$brr[$value['jjcp_gdbh']]/100000000,2));
-                        }
-                    }else{
-                        $subArray[$k] = 0;
-                    }
-                }else{
-                    $subArray[$k] = $rows[$key][$k];
-                }
-            }
-            array_push($data,$subArray);
-        }
-
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-
-    /**
-     * 各日统计列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     */
-    public function getDayList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [
-            'c.jjcp_smb'=>['<>',''],
-        ];
-        if (isset($req['key_word']) && !empty($req['key_word'])){
-            $where['c.jjcp_sj | c.jjcp_gdbh | c.jjcp_cpmc | c.jjcp_cpdh | g.实际投料'] = ['like','%'.$req['key_word'].'%'];
-        }
-
-        //客户编号
-        $rows = db('成品入仓')->alias('c')
-            ->field('LEFT(c.jjcp_sj, 10) as jjcp_sj, c.jjcp_gdbh, rtrim(c.jjcp_cpmc) as jjcp_cpmc, 
-            rtrim(c.jjcp_cpdh) as jjcp_cpdh, g.实际投料')
-            ->where($where)
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->order('c.jjcp_sj desc')
-            ->group('c.jjcp_gdbh, c.jjcp_cpdh')
-            ->page($page,$limit)
-            ->select();
-
-        $total = db('成品入仓')->alias('c')
-            ->where($where)
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->group('c.jjcp_gdbh, c.jjcp_cpdh')
-            ->count();
-
-        $brr = db('成品入仓')
-            ->group('jjcp_gdbh,jjcp_cpdh')
-            ->column('CONCAT(jjcp_gdbh, "-", rtrim(jjcp_cpdh)), sum(jjcp_sl)');
-
-        foreach ($rows as $key=>$value) {
-            $rows[$key]['实际投料'] = (string)floatval($value['实际投料']*10000);
-            if(array_key_exists($value['jjcp_gdbh'].'-'.$value['jjcp_cpdh'],$brr)){
-                $rows[$key]['入仓数量'] = $brr[$value['jjcp_gdbh'].'-'.$value['jjcp_cpdh']];
-                if($rows[$key]['实际投料']!=0){
-                    $rows[$key]['投入产出率'] = number_format($rows[$key]['入仓数量']/$rows[$key]['实际投料']*100,2);
-                }else{
-                    $rows[$key]['投入产出率'] = '';
-                }
-            }else{
-                $rows[$key]['入仓数量'] = '';
-                $rows[$key]['投入产出率'] = '';
-            }
-        }
-
-        $data = [
-            'total'          => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-
-    /**
-     * 各日统计列表excel导出
-     * @ApiMethod (POST)
-     * @param string file_name
-     * @param array fields
-     */
-    public function dayExport()
-    {
-        //get请求
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!isset($req['file_name'])){
-            $this->error('参数错误','file_name');
-        }
-
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-        if (isset($req['key_word']) && !empty($req['key_word'])){
-            $where['c.jjcp_sj | c.jjcp_gdbh | c.jjcp_cpmc | c.jjcp_cpdh | g.实际投料'] = ['like','%'.$req['key_word'].'%'];
-        }
-        $arr = [
-            'jjcp_gdbh'    =>['jjcp_gdbh'],
-            'jjcp_yjno'    =>['jjcp_yjno'],
-            'jjcp_cpmc'    =>['印件名称'],
-            '成品编码'      =>['成品编码'],
-            '成品名称'      =>['成品名称'],
-            '实际投料'      =>['实际投料'],
-            'jjcp_sls'     =>['入仓数量'],
-            'jjcp_sj'      =>['完工日期'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        $where = [
-            'c.jjcp_smb'=>['<>','']
-        ];
-
-        //客户编号
-        $rows = db('成品入仓')->alias('c')
-            ->field('c.jjcp_gdbh, c.jjcp_yjno, rtrim(c.jjcp_cpmc) as jjcp_cpmc, rtrim(c.jjcp_cpdh) as jjcp_cpdh, 
-            rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称, sum(jjcp_sl) as jjcp_sls, 
-            g.实际投料, LEFT(c.jjcp_sj, 10) as jjcp_sj
-            ')
-            ->where($where)
-            ->where('g.Gd_cpdh=c.jjcp_cpdh')
-            ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh')
-            ->order('c.jjcp_sj desc')
-            ->group('c.jjcp_gdbh, c.jjcp_cpdh')
-            ->select();
-
-        foreach ($rows as $key=>$value) {
-            $subArray = [];
-            foreach ($arr as $k=>$v){
-                if($k=='实际投料'){
-                    $subArray[$k] = (string)floatval($value['实际投料']*10000);
-                }else{
-                    $subArray[$k] = $rows[$key][$k];
-                }
-            }
-            array_push($data,$subArray);
-        }
-
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-    /**
-     * 入仓末板数据统计列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     */
-    public function mbList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        // $page = 1;
-        // $limit = 15;
-        // if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        // if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $date = date('Y-m-d',strtotime('-3 month'));
-        $arr1 = db('db_包装产量预报')
-            ->field('sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6, 
-            cast(substr(sczl_yjGx1,1,2) as signed) as sczl_yjGx1, cast(substr(sczl_yjGx2,1,2) as signed) as sczl_yjGx2, 
-            cast(substr(sczl_yjGx3,1,2) as signed) as sczl_yjGx3, cast(substr(sczl_yjGx4,1,2) as signed) as sczl_yjGx4, 
-            cast(substr(sczl_yjGx5,1,2) as signed) as sczl_yjGx5, cast(substr(sczl_yjGx6,1,2) as signed) as sczl_yjGx6, 
-            (sczl_cl1*sczl_PgCl1+sczl_clAdd1) as sczl_cls1, 
-            (sczl_cl2*sczl_PgCl2+sczl_clAdd2) as sczl_cls2, 
-            (sczl_cl3*sczl_PgCl3+sczl_clAdd3) as sczl_cls3, 
-            (sczl_cl4*sczl_PgCl4+sczl_clAdd4) as sczl_cls4, 
-            (sczl_cl5*sczl_PgCl5+sczl_clAdd5) as sczl_cls5, 
-            (sczl_cl6*sczl_PgCl6+sczl_clAdd6) as sczl_cls6
-            ')
-            ->where('sczl_rq','>=',$date)
-            ->select();
-
-        $data1 = [];
-        foreach ($arr1 as $k=>$v){
-            for ($i=1;$i<=6;$i++){
-                if(array_key_exists($v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i],$data1)){
-                    $data1[$v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i]] += $v['sczl_cls'.$i];
-                }else{
-                    $data1[$v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i]] = $v['sczl_cls'.$i];
-                }
-            }
-        }
-        krsort($data1);
-        
-        //成品入仓中jjcp_smb不为空的工单
-        $rows1 = db('成品入仓')
-            ->where('jjcp_smb','<>','')
-            ->order('jjcp_gdbh desc')
-            ->column("CONCAT(jjcp_gdbh, '-', jjcp_yjno) AS gdyj, UniqId");
-
-        $rows2 = db('成品入仓')
-            ->where('jjcp_sj','>=',$date)
-            ->group('jjcp_gdbh, jjcp_cpdh')
-            ->column("CONCAT( jjcp_gdbh, '-',  jjcp_yjno) AS gdyj, jjcp_smb,
-            sum(jjcp_sl) as jjcp_sls, left(max(jjcp_sj),10) as jjcp_sj");
-
-        $rows3 = db('工单_印件资料')->cache(true,86400)
-            ->group('Yj_Gdbh, yj_Yjno')
-            ->column("CONCAT( Yj_Gdbh, '-',  yj_Yjno) AS gdyj, 
-            Yj_Gdbh, yj_Yjno, yj_yjmc, yj_成品数量, yj_实际投料");
-        $data = [];
-        foreach($data1 as $key=>$value){
-            if(!array_key_exists($key,$rows1)){
-                $subArray = [];
-                if(array_key_exists($key,$rows3)){
-                    $subArray['Yj_Gdbh'] = $rows3[$key]['Yj_Gdbh'];
-                    $subArray['yj_Yjno'] = $rows3[$key]['yj_Yjno'];
-                    $subArray['yj_yjmc'] = trim($rows3[$key]['yj_yjmc']);
-                    $subArray['yj_成品数量'] = (string)floatval($rows3[$key]['yj_成品数量']*10000);
-                    $subArray['yj_实际投料'] = (string)floatval($rows3[$key]['yj_实际投料']*10000);
-                }else{
-                    $subArray['Yj_Gdbh'] = '';
-                    $subArray['yj_Yjno'] = '';
-                    $subArray['yj_yjmc'] = '';
-                    $subArray['yj_成品数量'] = '';
-                    $subArray['yj_实际投料'] = '';
-                }
-                
-                if(array_key_exists($key,$rows2)){
-                    $subArray['jjcp_smb'] = $rows2[$key]['jjcp_smb'];
-                    $subArray['jjcp_sls'] = $rows2[$key]['jjcp_sls'];
-                    $subArray['jjcp_sj'] = $rows2[$key]['jjcp_sj'];
-                }else{
-                    $subArray['jjcp_smb'] = '';
-                    $subArray['jjcp_sls'] = '';
-                    $subArray['jjcp_sj'] = '';
-                }
-                $subArray['sczl_cls'] = (string)floatval($value);
-                array_push($data,$subArray);
-            }
-        }
-
-
-        // $rows = db('db_包装产量预报')
-        //     ->field('sczl_rq,sczl_gdbh1,sczl_gdbh2,sczl_gdbh3,sczl_gdbh4,sczl_gdbh5,sczl_gdbh6,Sys_rq,mod_rq,UniqId')
-        //     ->where('Sys_rq','>=','2023-10-25')
-        //     ->select();
-        // $uniqueValues = [];
-        // foreach ($rows as $row) {
-        //     $gdbhArray = array($row['sczl_gdbh1'], $row['sczl_gdbh2'], $row['sczl_gdbh3'], $row['sczl_gdbh4'], $row['sczl_gdbh5'], $row['sczl_gdbh6']);
-        //     $uniqueValues = array_merge($uniqueValues, array_unique($gdbhArray));
-        // }
-
-        // $uniqueValues = array_values(array_unique($uniqueValues));
-        // halt($uniqueValues);
-        // $rows = db('成品入仓')->alias('c')
-        //     ->field('c.jjcp_gdbh, c.jjcp_yjno, rtrim(c.jjcp_cpmc) as jjcp_cpmc,
-        //     y.yj_成品数量, y.yj_实际投料, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_smb) as jjcp_smb,
-        //     sum(c.jjcp_sl) as jjcp_sls, left(max(c.Sys_rq),10) as Sys_rq')
-        //     ->where($where)
-        //     ->where('y.yj_Yjdh=c.jjcp_cpdh')
-        //     ->join('工单_印件资料 y','y.Yj_Gdbh=c.jjcp_gdbh')
-        //     ->order('c.jjcp_gdbh desc, c.jjcp_yjno asc')
-        //     ->group('c.jjcp_gdbh, c.jjcp_cpdh')
-        //     ->page($page,$limit)
-        //     ->select();
-
-        // $total = db('成品入仓')->alias('c')
-        //     ->where($where)
-        //     ->where('y.yj_Yjdh=c.jjcp_cpdh')
-        //     ->join('工单_印件资料 y','y.Yj_Gdbh=c.jjcp_gdbh')
-        //     ->group('c.jjcp_gdbh, c.jjcp_cpdh')
-        //     ->count();
-        // $brr = db('成品入仓')
-        //     ->group('jjcp_gdbh,jjcp_cpdh')
-        //     ->column('CONCAT(jjcp_gdbh, "-", rtrim(jjcp_cpdh)), sum(jjcp_sl)');
-
-        // $num = db('db_包装产量预报')->count();
-        // $arr1 = db('db_包装产量预报')
-        //     ->field('sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6, 
-        //     substr(sczl_yjGx1,2,1) as sczl_yjGx1, substr(sczl_yjGx2,2,1) as sczl_yjGx2, 
-        //     substr(sczl_yjGx3,2,1) as sczl_yjGx3, substr(sczl_yjGx4,2,1) as sczl_yjGx4, 
-        //     substr(sczl_yjGx5,2,1) as sczl_yjGx5, substr(sczl_yjGx6,2,1) as sczl_yjGx6, 
-        //     (sczl_cl1*sczl_PgCl1+sczl_clAdd1) as sczl_cls1, 
-        //     (sczl_cl2*sczl_PgCl2+sczl_clAdd2) as sczl_cls2, 
-        //     (sczl_cl3*sczl_PgCl3+sczl_clAdd3) as sczl_cls3, 
-        //     (sczl_cl4*sczl_PgCl4+sczl_clAdd4) as sczl_cls4, 
-        //     (sczl_cl5*sczl_PgCl5+sczl_clAdd5) as sczl_cls5, 
-        //     (sczl_cl6*sczl_PgCl6+sczl_clAdd6) as sczl_cls6
-        //     ')
-        //     ->limit($num)
-        //     ->select();
-
-        // $data1 = [];
-        // foreach ($arr1 as $k=>$v){
-        //     for ($i=1;$i<=6;$i++){
-        //         if(array_key_exists($v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i],$data1)){
-        //             $data1[$v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i]] += $v['sczl_cls'.$i];
-        //         }else{
-        //             $data1[$v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i]] = $v['sczl_cls'.$i];
-        //         }
-        //     }
-        // }
-
-        // foreach ($rows as $key=>$value) {
-        //     $rows[$key]['yj_成品数量'] = (string)floatval($value['yj_成品数量']*10000);
-        //     $rows[$key]['yj_实际投料'] = (string)floatval($value['yj_实际投料']*10000);
-        //     if(array_key_exists($value['jjcp_gdbh'].'-'.$value['jjcp_yjno'],$data1)){
-        //         $rows[$key]['包装产量'] = $data1[$value['jjcp_gdbh'].'-'.$value['jjcp_yjno']];
-        //     }else{
-        //         $rows[$key]['包装产量'] = '';
-        //     }
-        //     if(array_key_exists($value['jjcp_gdbh'].'-'.$value['jjcp_cpdh'],$brr)){
-        //         $rows[$key]['入仓数量'] = $brr[$value['jjcp_gdbh'].'-'.$value['jjcp_cpdh']];
-        //     }else{
-        //         $rows[$key]['入仓数量'] = '';
-        //     }
-        //     if($value['jjcp_smb'] !=''){
-        //         $rows[$key]['状态'] = '完工';
-        //         $rows[$key]['缺数'] = (int)$rows[$key]['yj_成品数量']-(int)$rows[$key]['包装产量'];
-        //     }else{
-        //         $rows[$key]['状态'] = '';
-        //         $rows[$key]['缺数'] = '';
-        //     }
-        // }
-
-        $data = [
-            'total'         => count($data),
-            'rows'          => $data,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 入仓末板数据统计列表excel导出
-     * @ApiMethod (POST)
-     * @param string file_name
-     * @param array fields
-     */
-    public function mbExport()
-    {
-        //get请求
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!isset($req['file_name'])){
-            $this->error('参数错误','file_name');
-        }
-
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-
-        $arr = [
-            'Yj_Gdbh'       =>['工单编号'],
-            'yj_Yjno'       =>['印件号'],
-            'yj_yjmc'       =>['印件名称'],
-            'yj_成品数量'    =>['计划交货数量'],
-            'yj_实际投料'    =>['印件投料'],
-            'sczl_cls'      =>['包装产量'],
-            'jjcp_sj'       =>['最近入仓时间'],
-            'jjcp_sls'      =>['入仓产量'],
-            'status'        =>['完工'],
-            '缺数'          =>['缺数'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-        $date = date('Y-m-d',strtotime('-3 month'));
-        $arr1 = db('db_包装产量预报')
-            ->field('sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6, 
-            cast(substr(sczl_yjGx1,1,2) as signed) as sczl_yjGx1, cast(substr(sczl_yjGx2,1,2) as signed) as sczl_yjGx2, 
-            cast(substr(sczl_yjGx3,1,2) as signed) as sczl_yjGx3, cast(substr(sczl_yjGx4,1,2) as signed) as sczl_yjGx4, 
-            cast(substr(sczl_yjGx5,1,2) as signed) as sczl_yjGx5, cast(substr(sczl_yjGx6,1,2) as signed) as sczl_yjGx6, 
-            (sczl_cl1*sczl_PgCl1+sczl_clAdd1) as sczl_cls1, 
-            (sczl_cl2*sczl_PgCl2+sczl_clAdd2) as sczl_cls2, 
-            (sczl_cl3*sczl_PgCl3+sczl_clAdd3) as sczl_cls3, 
-            (sczl_cl4*sczl_PgCl4+sczl_clAdd4) as sczl_cls4, 
-            (sczl_cl5*sczl_PgCl5+sczl_clAdd5) as sczl_cls5, 
-            (sczl_cl6*sczl_PgCl6+sczl_clAdd6) as sczl_cls6
-            ')
-            ->where('sczl_rq','>=',$date)
-            ->select();
-
-        $data1 = [];
-        foreach ($arr1 as $k=>$v){
-            for ($i=1;$i<=6;$i++){
-                if(array_key_exists($v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i],$data1)){
-                    $data1[$v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i]] += $v['sczl_cls'.$i];
-                }else{
-                    $data1[$v['sczl_gdbh'.$i].'-'.$v['sczl_yjGx'.$i]] = $v['sczl_cls'.$i];
-                }
-            }
-        }
-        krsort($data1);
-        
-        //成品入仓中jjcp_smb不为空的工单
-        $rows1 = db('成品入仓')
-            ->where('jjcp_smb','<>','')
-            ->order('jjcp_gdbh desc')
-            ->column("CONCAT(jjcp_gdbh, '-', jjcp_yjno) AS gdyj, UniqId");
-
-        $rows2 = db('成品入仓')
-            ->where('jjcp_sj','>=',$date)
-            ->group('jjcp_gdbh, jjcp_cpdh')
-            ->column("CONCAT( jjcp_gdbh, '-',  jjcp_yjno) AS gdyj, jjcp_smb,
-            sum(jjcp_sl) as jjcp_sls, left(max(jjcp_sj),10) as jjcp_sj");
-
-        $rows3 = db('工单_印件资料')->cache(true,86400)
-            ->group('Yj_Gdbh, yj_Yjno')
-            ->column("CONCAT( Yj_Gdbh, '-',  yj_Yjno) AS gdyj, 
-            Yj_Gdbh, yj_Yjno, yj_yjmc, yj_成品数量, yj_实际投料");
-
-        foreach($data1 as $key=>$value){
-            if(!array_key_exists($key,$rows1)){
-                $subArray = [];
-                foreach ($arr as $k=>$v){
-                    if($k=='yj_成品数量' || $k=='yj_实际投料'){
-                        if(array_key_exists($key,$rows3)){
-                            $subArray[$k] = (string)floatval($rows3[$key][$k]*10000);
-                        }else{
-                            $subArray[$k] = '';
-                        }
-                    }else if($k=='Yj_Gdbh' || $k=='yj_Yjno'){
-                        if(array_key_exists($key,$rows3)){
-                            $subArray[$k] = $rows3[$key][$k];
-                        }else{
-                            $subArray[$k] = '';
-                        }
-                    }else if($k=='yj_yjmc'){
-                        if(array_key_exists($key,$rows3)){
-                            $subArray[$k] = trim($rows3[$key][$k]);
-                        }else{
-                            $subArray[$k] = '';
-                        }
-                    }else if($k=='sczl_cls'){
-                        $subArray[$k] = (string)floatval($value);
-                    }else if($k=='status'){
-                        if(array_key_exists($key,$rows2) && $rows2[$key]['jjcp_smb'] !=''){
-                            $subArray[$k] = '完工';
-                        }else{
-                            $subArray[$k] = '';
-                        }
-                    }else if($k=='缺数'){
-                        if(array_key_exists($key,$rows2) && $rows2[$key]['jjcp_smb'] !=''){
-                            $subArray[$k]['缺数'] = (int)$rows3[$key]['yj_成品数量']-(int)$value;
-                        }else{
-                            $subArray[$k] = '';
-                        }
-                    }else{
-                        if(array_key_exists($key,$rows2)){
-                            $subArray[$k] = $rows2[$key][$k];
-                            $subArray[$k] = $rows2[$key][$k];
-                            $subArray[$k] = $rows2[$key][$k];
-                        }else{
-                            $subArray[$k] = '';
-                            $subArray[$k] = '';
-                            $subArray[$k] = '';
-                        }
-                    }
-                }
-                array_push($data,$subArray);
-            }
-        }
-
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-}

+ 0 - 437
application/api/controller/LargeWasteRewardPunish.php

@@ -1,437 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use think\db;
-use think\Request;
-
-/**
- * 工序大废品惩奖记录接口
- */
-class LargeWasteRewardPunish extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取工序大废品惩奖侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $rows = db()->table('db_大废品')
-            ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
-            ->group('date')
-            ->order('UniqId desc')
-            ->limit(40)
-            ->select();
-
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
-        }
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取工序大废品惩奖侧边栏根据工单
-     * @ApiMethod (GET)
-     */
-    public function getTabByGd()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $rows = db()->table('db_大废品')
-            ->field('sczl_gdbh,rtrim(g.成品名称) as 成品名称')
-            ->join('工单_基本资料 g','g.Gd_gdbh=db_大废品.sczl_gdbh','LEFT')
-            ->group('sczl_gdbh')
-            ->whereTime('db_大废品.sys_rq', '>=', strtotime('-60 days'))
-            ->order('sczl_gdbh desc')
-            ->select();
-        foreach($rows as $key=>$value){
-            $data[$key]['label']=$value['sczl_gdbh'].' 【'.$value['成品名称'].'】';
-            $data[$key]['sczl_gdbh']=$value['sczl_gdbh'];
-        }
-        $this->success('成功',$data);
-    }
-    /**
-     * 获取工序大废品惩奖列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['sys_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
-        }
-        $res = db()->table('db_大废品')
-        ->field('sczl_gdbh, LEFT(sczl_rq, 10) as sczl_rq, rtrim(sczl_numDesc) as sczl_numDesc, sczl_ls, sczl_yjno, 
-        rtrim(责任部门) as 责任部门, CAST(sczl_cl AS SIGNED) as sczl_cl, 
-        rtrim(sczl_fplxA) as sczl_fplxA, sczl_fplxB, Jl_bzdh, JL_bh1, 
-        sczl_bzdh, sczl_bh1, sczl_bh2, rtrim(sys_id) as sys_id, sys_rq, UniqId')
-        ->where('sczl_gdbh',$req['date'])
-        ->order('UniqId desc')
-        ->page($page,$limit)
-        ->select();
-        if($res){
-            $rows=$res;
-            $total = db()->table('db_大废品')->where('sczl_gdbh',$req['date'])->count();;
-        }else{
-            $rows = db()->table('db_大废品')
-            ->field('sczl_gdbh, LEFT(sczl_rq, 10) as sczl_rq, rtrim(sczl_numDesc) as sczl_numDesc, sczl_ls, sczl_yjno, 
-            rtrim(责任部门) as 责任部门, CAST(sczl_cl AS SIGNED) as sczl_cl, 
-            rtrim(sczl_fplxA) as sczl_fplxA, sczl_fplxB, Jl_bzdh, JL_bh1, 
-            sczl_bzdh, sczl_bh1, sczl_bh2, rtrim(sys_id) as sys_id, sys_rq, UniqId')
-            ->where($where)
-            ->order('UniqId desc')
-            ->page($page,$limit)
-            ->select();
-           $total = db()->table('db_大废品')->where($where)->count();
-        }
-        $gd = db()->table('工单_印件资料')->column('Yj_Gdbh, yj_yjmc');
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value) {
-            $rows[$key]['yj_yjmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? sprintf("%02d", $value['sczl_yjno']).'-'.trim($gd[$value['sczl_gdbh']]) : '';
-            $rows[$key]['JL_bh1'] = array_key_exists($value['JL_bh1'],$rs) ? trim($rs[$value['JL_bh1']]) : '';
-            $rows[$key]['sczl_bh1'] = array_key_exists($value['sczl_bh1'],$rs) ? trim($rs[$value['sczl_bh1']]) : '';
-            $rows[$key]['sczl_bh2'] = array_key_exists($value['sczl_bh2'],$rs) ? trim($rs[$value['sczl_bh2']]) : '';
-            $rows[$key]['sczl_fplxB'] = $value['sczl_fplxB'] == 1 ? '制程废' : '';
-            unset($rows[$key]['sczl_yjno']);
-        }
-
-        $data = [
-            'total'          => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取工序大废品惩奖信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db()->table('db_大废品')->alias('d')
-            ->field('sczl_gdbh,rtrim(g.Gd_cpmc) as Gd_cpmc,sczl_yjno,rtrim(yj.yj_yjmc) as yj_yjmc,
-            rtrim(sczl_gxmc) as sczl_gxmc,sczl_gxh,rtrim(sczl_numDesc) as sczl_numDesc,LEFT(sczl_rq, 10)
-            as sczl_rq,sczl_cl,sczl_ls,rtrim(sczl_fplxA) as sczl_fplxA,sczl_fplxB,rtrim(责任部门) as 责任部门,
-            rtrim(Jl_bzdh) as Jl_bzdh,jl_jtbh,JL_bh1,JL_bh2,JL_bh3,JL_bh4,JL_bh5,JL_bh6,JL_bh7,JL_bh8,JL_bh9,
-            rtrim(jl1.员工姓名) as jlname1,rtrim(jl2.员工姓名) as jlname2,rtrim(jl3.员工姓名) as jlname3
-            ,rtrim(jl4.员工姓名) as jlname4,rtrim(jl5.员工姓名) as jlname5,rtrim(jl6.员工姓名) as jlname6
-            ,rtrim(jl7.员工姓名) as jlname7,rtrim(jl8.员工姓名) as jlname8,rtrim(jl9.员工姓名) as jlname9
-            ,JL_Je1,JL_Je2,JL_Je3,JL_Je4,JL_Je5,JL_Je6,JL_Je7,JL_Je8,JL_Je9,rtrim(sczl_bzdh) as sczl_bzdh,
-            sczl_jtbh,sczl_bh1,sczl_bh2,sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,
-            rtrim(Jl_bzdh) as Jl_bzdh,jl_jtbh,JL_bh1,JL_bh2,JL_bh3,JL_bh4,JL_bh5,JL_bh6,JL_bh7,JL_bh8,JL_bh9,
-            rtrim(zr1.员工姓名) as zrname1,rtrim(zr2.员工姓名) as zrname2,rtrim(zr3.员工姓名) as zrname3
-            ,rtrim(zr4.员工姓名) as zrname4,rtrim(zr5.员工姓名) as zrname5,rtrim(zr6.员工姓名) as zrname6
-            ,rtrim(zr7.员工姓名) as zrname7,rtrim(zr8.员工姓名) as zrname8,rtrim(zr9.员工姓名) as zrname9
-            ,sczl_je1,sczl_je2,sczl_je3,sczl_je4,sczl_je5,sczl_je6,sczl_je7,sczl_je8,sczl_je9')
-           ->join('工单_基本资料 g','g.Gd_gdbh=db_大废品.sczl_gdbh')
-           ->join('工单_印件资料 yj','yj.Yj_Gdbh=db_大废品.sczl_gdbh','LEFT')
-           ->join('人事_基本资料 jl1','jl1.员工编号=db_大废品.JL_bh1','LEFT')
-           ->join('人事_基本资料 jl2','jl2.员工编号=db_大废品.JL_bh2','LEFT')
-           ->join('人事_基本资料 jl3','jl3.员工编号=db_大废品.JL_bh3','LEFT')
-           ->join('人事_基本资料 jl4','jl4.员工编号=db_大废品.JL_bh4','LEFT')
-           ->join('人事_基本资料 jl5','jl5.员工编号=db_大废品.JL_bh5','LEFT')
-           ->join('人事_基本资料 jl6','jl6.员工编号=db_大废品.JL_bh6','LEFT')
-           ->join('人事_基本资料 jl7','jl7.员工编号=db_大废品.JL_bh7','LEFT')
-           ->join('人事_基本资料 jl8','jl8.员工编号=db_大废品.JL_bh8','LEFT')
-           ->join('人事_基本资料 jl9','jl9.员工编号=db_大废品.JL_bh9','LEFT')
-           ->join('人事_基本资料 zr1','zr1.员工编号=db_大废品.sczl_bh1','LEFT')
-           ->join('人事_基本资料 zr2','zr2.员工编号=db_大废品.sczl_bh2','LEFT')
-           ->join('人事_基本资料 zr3','zr3.员工编号=db_大废品.sczl_bh3','LEFT')
-           ->join('人事_基本资料 zr4','zr4.员工编号=db_大废品.sczl_bh4','LEFT')
-           ->join('人事_基本资料 zr5','zr5.员工编号=db_大废品.sczl_bh5','LEFT')
-           ->join('人事_基本资料 zr6','zr6.员工编号=db_大废品.sczl_bh6','LEFT')
-           ->join('人事_基本资料 zr7','zr7.员工编号=db_大废品.sczl_bh7','LEFT')
-           ->join('人事_基本资料 zr8','zr8.员工编号=db_大废品.sczl_bh8','LEFT')
-           ->join('人事_基本资料 zr9','zr9.员工编号=db_大废品.sczl_bh9','LEFT')
-            ->where('d.UniqId',$UniqId)->limit(1)->select();
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 工单编号获取
-     * @return void
-     * @throws \think\exception\DbException
-     * @throws db\exception\DataNotFoundException
-     * @throws db\exception\ModelNotFoundException
-     */
-    public function JunkWorkOrderList()
-    {
-        if ($this->request->isGet() === false){
-            $this->error('非法请求');
-        }
-        $params = $this->request->param();
-        if (empty($params['search'])){
-            $this->error('参数错误');
-        }
-        $list = \db('工单_基本资料')
-            ->field('rtrim(Gd_gdbh) as 工单编号,rtrim(成品名称) as 产品名称')
-            ->where('Gd_gdbh','like','%'.$params['search'].'%')
-            ->select();
-        if (empty($list)){
-            $this->success('未找到工单信息');
-        }
-        $this->success('成功',$list);
-    }
-
-    /**
-     * 印件编号获取
-     * @return void
-     * @throws \think\exception\DbException
-     * @throws db\exception\DataNotFoundException
-     * @throws db\exception\ModelNotFoundException
-     */
-    public function PrintCodeList()
-    {
-        if ($this->request->isGet() === false){
-            $this->error('非法请求');
-        }
-        $param = $this->request->param();
-        if (empty($param['workorder'])){
-            $this->error('参数错误');
-        }
-        $list = \db('工单_印件资料')
-            ->field('rtrim(yj_Yjno) as 印件号,rtrim(yj_yjmc) as 印件名称')
-            ->where('Yj_Gdbh',$param['workorder'])
-            ->select();
-        if (empty($list)){
-            $this->success('未找到该工单印件');
-        }
-        $this->success('成功',$list);
-    }
-
-    /**
-     * 工单工序获取
-     * @return void
-     * @throws \think\exception\DbException
-     * @throws db\exception\DataNotFoundException
-     * @throws db\exception\ModelNotFoundException
-     */
-    public function ProcessList()
-    {
-        if ($this->request->isGet() === false){
-            $this->error('非法请求');
-        }
-        $param = $this->request->param();
-        if (empty($param['workorder']) || empty($param['yjno'])){
-            $this->error('参数错误');
-        }
-        $list = \db('工单_工艺资料')
-            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc')
-            ->where('Gy0_gdbh',$param['workorder'])
-            ->where('Gy0_yjno',$param['yjno'])
-            ->select();
-        if (empty($list)){
-            $this->success('未找到该工单工艺');
-        }
-        $data = [];
-        foreach ($list as $key=>$value){
-            if ((int)$value['gxh'] < 10){
-                $value['gxh'] = '0'.$value['gxh'];
-            }
-            $data[$key] = $value['gxh'].'-'.$value['gxmc'];
-        }
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 机台编号获取
-     * @return void
-     * @throws \think\exception\DbException
-     * @throws db\exception\DataNotFoundException
-     * @throws db\exception\ModelNotFoundException
-     */
-    public function MachineList()
-    {
-        if ($this->request->isGet() === false){
-            $this->error('非法请求');
-        }
-        $list = \db('设备_基本资料')
-            ->field('rtrim(设备编号) as 设备编号')
-            ->where('sys_sbID','<>','')
-            ->select();
-        if (empty($list)){
-            $this->success('未找到机台编号');
-        }
-        $this->success('成功',$list);
-    }
-
-    /**
-     * 机台班组获取
-     * @return void
-     * @throws \think\exception\DbException
-     * @throws db\exception\DataNotFoundException
-     * @throws db\exception\ModelNotFoundException
-     */
-    public function MachineClassList()
-    {
-        if ($this->request->isGet() === false){
-            $this->error('非法请求');
-        }
-        $param = $this->request->param();
-        if (empty($param['machine'])){
-            $this->error('参数错误');
-        }
-        $list = \db('设备_班组资料')
-            ->where('sczl_jtbh',$param['machine'])
-            ->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,rtrim(sczl_bzdh) as 班组代号')
-            ->select();
-        if (empty($list)){
-            $this->success('未找到该机台班组');
-        }
-        foreach ($list as $key=>$value){
-            for ($i=1;$i<=10;$i++){
-                if (!empty($value['bh'.$i])){
-                    $name = \db('人事_基本资料')->where('员工编号',$value['bh'.$i])->field('rtrim(员工姓名) as name')->find();
-                    if (isset($name['name'])){
-                        $list[$key]['组员'.$i] = [
-                            '编号' => $value['bh'.$i],
-                            '姓名' => $name['name']
-                        ];
-                    }
-                }else{
-                    $list[$key]['组员'.$i] = [
-                        '编号' => '',
-                        '姓名' => ''
-                    ];
-                }
-                unset($list[$key]['bh'.$i]);
-            }
-        }
-        $this->success('成功',$list);
-    }
-
-    /**
-     * 大废品数据修改
-     * @return void
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     * @throws db\exception\BindParamException
-     */
-    public function JunkDetailEdit()
-    {
-        if (Request::instance()->isPost() === false){
-            $this->error('非法请求');
-        }
-        $param = Request::instance()->post();
-        if (empty($param['sczl_gdbh']) || empty($param['UniqId'])){
-            $this->error('参数错误');
-        }
-        $param['mod_rq'] = date('Y-m-d H:i:s',time());
-        $data = $param;
-        unset($data['UniqId']);
-        $sql = \db('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\exception\PDOException
-     * @throws db\exception\BindParamException
-     */
-    public function JunkDetailAdd()
-    {
-        if (Request::instance()->isPost() === false){
-            $this->error('非法请求');
-        }
-        $param = Request::instance()->post();
-        if (empty($param['sczl_gdbh'])){
-            $this->error('参数错误');
-        }
-        $lastID = \db('db_大废品')->order('UniqId desc')->value('UniqId');
-        $param['sys_rq'] = date('Y-m-d H:i:s',time());
-        $param['mod_rq'] = '1900-01-01 00:00:00';
-        $param['UniqId'] = $lastID + 1;
-        $sql = \db('db_大废品')->fetchSql(true)->insert($param);
-        $res = \db()->query($sql);
-        if ($res !== false){
-            $this->success('添加成功');
-        }else{
-            $this->error('失败');
-        }
-    }
-
-    /**
-     * 大废品数据删除
-     * @return void
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public function JunkDetailDel()
-    {
-        if ($this->request->isGet() === false){
-            $this->error('非法请求');
-        }
-        $param = $this->request->param();
-        if (empty($param['UniqId'])){
-            $this->error('参数错误');
-        }
-        $idList = explode(',',$param['UniqId']);
-        $res = \db('db_大废品')
-            ->whereIn('UniqId',$idList)
-            ->delete();
-        if ($res !== false){
-            $this->success('删除成功');
-        }else{
-            $this->error('失败');
-        }
-    }
-}

+ 0 - 1070
application/api/controller/MachineProductionReport.php

@@ -1,1070 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-
-/**
- * 机台生产日报表维护接口
- */
-class MachineProductionReport extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取机台生产日报表侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-
-        $time = date('Y-m-d',time()-8640000);
-        $sql = 'SELECT date, COUNT(*) as counts
-            FROM (
-                SELECT LEFT(sys_rq, 10) as date FROM db_sczl WHERE sys_rq > "'.$time.'"
-            UNION ALL
-                SELECT LEFT(sys_rq, 10) as date FROM 设备_产量计酬 WHERE sys_rq > "'.$time.'"
-            ) AS t1
-            GROUP BY date
-            ORDER BY date DESC
-            LIMIT 30';
-        $rows = db()->query($sql);
-
-        if(count($rows) < 30){
-            $sql = 'SELECT date, COUNT(*) as counts
-            FROM (
-                SELECT LEFT(sys_rq, 10) as date FROM db_sczl WHERE sys_rq > "2023-11-01"
-            UNION ALL
-                SELECT LEFT(sys_rq, 10) as date FROM 设备_产量计酬 WHERE sys_rq > "2023-11-01"
-            ) AS t1
-            GROUP BY date
-            ORDER BY date DESC
-            LIMIT 30';
-        $rows = db()->query($sql);
-       }
-
-        $sql = 'SELECT date, sys_id, COUNT(*) as count
-            FROM (
-                SELECT LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id 
-                FROM db_sczl WHERE sys_rq >= "'.$rows[count($rows)-1]['date'].'"
-            UNION ALL
-                SELECT LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id 
-                FROM 设备_产量计酬 WHERE sys_rq >= "'.$rows[count($rows)-1]['date'].'"
-            ) AS t1
-            GROUP BY date, sys_id';
-        $data = db()->query($sql);
-        
-        $result = [];
-        foreach ($data as $item) {
-            $date = $item['date'];
-            $sysId = $item['sys_id'];
-            $count = $item['count'];
-
-            // 如果结果数组中不存在该日期和系统ID的记录,则创建新记录
-            if (!isset($result[$date][$sysId])) {
-                if (substr($sysId,1,3)=='00-'){
-                    if (isset($result[$date])){
-                        $result[$date] = array_merge([$sysId=>0],$result[$date]);
-                    }else{
-                        $result[$date][$sysId] = 0;
-                    }
-                }else{
-                    $result[$date][$sysId] = 0;
-                }
-            }
-
-            // 将count累加到对应的记录中
-            $result[$date][$sysId] += $count;
-        }
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['sys'] = $result[$value['date']];
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 通过工单获取机台生产日报表侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTabByGdbh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-
-        $date = date('Y-m-d',strtotime("-1 year"));
-        $sql = 'SELECT t1.`sczl_gdbh`,t2.`yj_yjmc`
-        FROM (
-            SELECT DISTINCT `sczl_gdbh`, sczl_yjno FROM `db_sczl` where sys_rq >"'.$date.'"
-            UNION
-            SELECT  DISTINCT `sczl_gdbh`, sczl_yjno FROM `设备_产量计酬` where sys_rq >"'.$date.'"
-        ) AS t1
-        JOIN `工单_印件资料` AS t2 ON t1.`sczl_gdbh` = t2.`Yj_Gdbh`
-        WHERE t1.sczl_yjno = t2.yj_Yjno
-        ORDER BY t1.`sczl_gdbh` DESC
-        LIMIT 65';
-        $rows = db()->query($sql);
-
-        $sql = 'SELECT sczl_gdbh,rtrim(sys_id) as sys_id
-            FROM (
-                SELECT sczl_gdbh,rtrim(sys_id) as sys_id
-                FROM db_sczl WHERE sczl_gdbh >= "'.$rows[count($rows)-1]['sczl_gdbh'].'"
-            UNION ALL
-                SELECT sczl_gdbh,rtrim(sys_id) as sys_id
-                FROM 设备_产量计酬 WHERE sczl_gdbh >= "'.$rows[count($rows)-1]['sczl_gdbh'].'"
-            ) AS t1
-            ORDER BY sys_id';
-        $arr = db()->query($sql);
-
-        $brr = [];
-        foreach($arr as $k=>$v){
-            if(array_key_exists($v['sczl_gdbh'],$brr)){
-                if(array_key_exists($v['sys_id'],$brr[$v['sczl_gdbh']])){
-                    $brr[$v['sczl_gdbh']][$v['sys_id']] += 1;
-                }else{
-                    $brr[$v['sczl_gdbh']][$v['sys_id']] = 1;
-                }
-            }else{
-                $brr[$v['sczl_gdbh']][$v['sys_id']] = 1;
-            }
-        }
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['sys'] = $brr[$value['sczl_gdbh']];
-            $rows[$key]['yj_yjmc'] = trim($value['yj_yjmc']);
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取机台生产日报表列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!isset($req['date']) || empty($req['date'])) $this->error('参数缺失');
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        //获取total
-        $sql = 'SELECT sum(count) AS count FROM (
-            SELECT COUNT(*) AS count FROM `设备_产量计酬` ';
-            $sql .= strpos($req['date'],'-') ? 'WHERE `sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `sczl_gdbh` = "'.$req['date'].'" ';
-            $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `sys_id` LIKE "'.$req['sys_id'].'%" ' : '';
-            $sql .= 'UNION ALL SELECT COUNT(*) AS count FROM `db_sczl`';
-            $sql .= strpos($req['date'],'-') ? 'WHERE `sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `sczl_gdbh` = "'.$req['date'].'" ';
-            $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `sys_id` LIKE "'.$req['sys_id'].'%" ' : '';
-            $sql .= ') as t';
-        $total = db()->query($sql)[0]['count'];
-
-        if (cache('MachineProductReport-getList')){
-            if(array_key_exists($req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit'] , cache('MachineProductReport-getList'))){
-                $rows = cache('MachineProductReport-getList')[$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']];
-            }else{
-                //UNION 查询两表数据
-                // db_sczl缺少数据 --> a.sczl_来料少数,
-                // 设备_产量计酬缺少数据 --> a.拆片联拼系数, a.拆片条小盒系数,
-                $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                            a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                            a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                            d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                            rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
-                        FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
-                $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` = "'.$req['sys_id'].'" ' : '';
-                $sql .= 'UNION ALL
-                        SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                            a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                            a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                            d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
-                            rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
-                        FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
-                $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
-                $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` = "'.$req['sys_id'].'" ' : '';
-                $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
-                $rows = db()->query($sql);
-
-                //设置缓存
-                $cache = cache('MachineProductReport-getList');
-                $cache[$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']] = $rows;
-                cache('MachineProductReport-getList',$cache,3600);
-            }
-        }else{
-            //UNION 查询两表数据
-            // db_sczl缺少数据 --> a.sczl_来料少数,
-            // 设备_产量计酬缺少数据 --> a.拆片联拼系数, a.拆片条小盒系数,
-            $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                        a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                        a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                        a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                        d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                        rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
-                    FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-            $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
-            $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` = "'.$req['sys_id'].'" ' : '';
-            $sql .= 'UNION ALL
-                    SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                        a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                        a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                        a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                        d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
-                        rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
-                    FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
-            $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
-            $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` = "'.$req['sys_id'].'" ' : '';
-            $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
-            $rows = db()->query($sql);
-
-            //设置缓存
-            $cache = [];
-            $cache[$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']] = $rows;
-            cache('MachineProductReport-getList',$cache,3600);
-        }
-
-        $gd = db('工单_基本资料')->cache(true,3600)->column('Gd_gdbh, 成品名称 as Gd_cpmc');
-        $rs = db('人事_基本资料')->cache(true,3600)->column('员工编号, 员工姓名');
-        
-        foreach ($rows as $key=>$value){
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['Gd_cpmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? trim($gd[$value['sczl_gdbh']]) : '';
-            $rows[$key]['name1'] = array_key_exists($value['sczl_bh1'],$rs) ? trim($rs[$value['sczl_bh1']]) : '';
-            for ($i=2;$i<=6;$i++){
-                if ($value['sczl_bh'.$i]){
-                    if ($value['sczl_bh'.$i]==$value['sczl_bh1']){
-                        $rows[$key]['name'.$i] = $rows[$key]['name1'];
-                    }else{
-                        $rows[$key]['name'.$i] = array_key_exists($value['sczl_bh'.$i],$rs) ? trim($rs[$value['sczl_bh'.$i]]) : '';
-                    }
-                }else{
-                    $rows[$key]['name'.$i] = '';
-                }
-            }
-            $rows[$key]['jyno_gxmc'] = sprintf("%02d", $value['sczl_yjno']).'-'.sprintf("%02d", $value['sczl_gxh']).'-->'.trim($value['sczl_type']);
-            $rows[$key]['sczl_num'] = $value['sczl_num'] == 0 ? '' : $value['sczl_num'];
-            $rows[$key]['sczl_cl'] = $value['sczl_cl'] == 0 ? '' : floatval($value['sczl_cl']);
-            $rows[$key]['sczl_ms'] = $value['sczl_ms'] == 0 ? 1 : floatval($value['sczl_ms']);
-            $rows[$key]['sczl_zcfp'] = $value['sczl_zcfp'] == 0 ? '' : floatval($value['sczl_zcfp']);
-            $rows[$key]['sczl_zccp'] = $value['sczl_zccp'] == 0 ? '' : floatval($value['sczl_zccp']);
-            $rows[$key]['sczl_装版工时'] = $value['sczl_装版工时'] == 0 ? '' : floatval($value['sczl_装版工时']);
-            $rows[$key]['sczl_保养工时'] = $value['sczl_保养工时'] == 0 ? '' : floatval($value['sczl_保养工时']);
-            $rows[$key]['sczl_打样工时'] = $value['sczl_打样工时'] == 0 ? '' : floatval($value['sczl_打样工时']);
-            $rows[$key]['sczl_异常停机工时'] = $value['sczl_异常停机工时'] == 0 ? '' : floatval($value['sczl_异常停机工时']);
-            $rows[$key]['sczl_设备运行工时'] = $value['sczl_设备运行工时'] == 0 ? '' : floatval($value['sczl_设备运行工时']);
-            $rows[$key]['sczl_工价系数'] = $value['sczl_工价系数'] == 0 ? '' : floatval($value['sczl_工价系数']);
-            $rows[$key]['千件工价'] = $value['千件工价'] == 0 ? '' : floatval($value['千件工价']);
-            $rows[$key]['sczl_来料少数'] = $value['sczl_来料少数'] == 0 ? '' : floatval($value['sczl_来料少数']);
-            $rows[$key]['拆片联拼系数'] = $value['拆片联拼系数'] == 0 ? '' : floatval($value['拆片联拼系数']);
-            $rows[$key]['拆片条小盒系数'] = $value['拆片条小盒系数'] == 0 ? '' : floatval($value['拆片条小盒系数']);
-
-            unset($rows[$key]['sczl_yjno']);
-            unset($rows[$key]['sczl_gxh']);
-            unset($rows[$key]['sczl_type']);
-        }
-
-        $data = [
-            'total'         => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 定位
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $cpmc 产品名称
-     * @param string $page 页码
-     * @param string $limit 数量
-     */
-    public function locate()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            //获取total
-            $sql = 'SELECT sum(count) AS count FROM (
-                SELECT COUNT(*) AS count FROM `设备_产量计酬` ';
-                $sql .= 'WHERE `sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
-                $sql .= 'UNION ALL SELECT COUNT(*) AS count FROM `db_sczl`';
-                $sql .= 'WHERE `sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
-                $sql .= ') as t';
-            $total = db()->query($sql)[0]['count'];
-
-            //判断缓存是否存在
-            if (cache('MachineProductReport-getList')){
-                if(array_key_exists($req['gdbh'].'-'.$req['page'].'-'.$req['limit'] , cache('MachineProductReport-getList'))){
-                    $rows = cache('MachineProductReport-getList')[$req['gdbh'].'-'.$req['page'].'-'.$req['limit']];
-                }else{
-                    //a.拆片联拼系数, a.拆片条小盒系数,
-                    $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                                a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                                a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                                a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                                d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                                rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
-                            FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                    $sql .= 'WHERE `a`.`sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
-                    $sql .= 'UNION ALL
-                            SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                                a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                                a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                                a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                                d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
-                                rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
-                            FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
-                    $sql .= 'WHERE `a`.`sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
-                    $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
-                    $rows = db()->query($sql);
-
-                    //设置缓存
-                    $cache = cache('MachineProductReport-getList');
-                    $cache[$req['gdbh'].'-'.$req['page'].'-'.$req['limit']] = $rows;
-                    cache('MachineProductReport-getList',$cache,3600);
-                }
-            }else{
-                //a.拆片联拼系数, a.拆片条小盒系数,
-                $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                            a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                            a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                            d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                            rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
-                        FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                $sql .= 'WHERE `a`.`sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
-                $sql .= 'UNION ALL
-                        SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                            a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                            a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                            a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                            d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
-                            rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
-                        FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
-                $sql .= 'WHERE `a`.`sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
-                $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
-                $rows = db()->query($sql);
-
-                //设置缓存
-                $cache = [];
-                $cache[$req['gdbh'].'-'.$req['page'].'-'.$req['limit']] = $rows;
-                cache('MachineProductReport-getList',$cache,3600);
-            } 
-            
-        }else{
-            if (isset($req['cpmc']) && !empty($req['cpmc'])){
-                //查询包括该名称的工单号
-                $gd = db('工单_基本资料')
-                    ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
-                    ->column('Gd_gdbh');
-                $in = "'" . implode("','", $gd) . "'";
-
-                //获取total
-                $sql = 'SELECT sum(count) AS count FROM (
-                    SELECT COUNT(*) AS count FROM `设备_产量计酬` ';
-                    $sql .= 'WHERE `sczl_gdbh` IN ('.$in.') ';
-                    $sql .= 'UNION ALL SELECT COUNT(*) AS count FROM `db_sczl`';
-                    $sql .= 'WHERE `sczl_gdbh` IN ('.$in.') ';
-                    $sql .= ') as t';
-                $total = db()->query($sql)[0]['count'];
-
-                //判断缓存是否存在
-                if (cache('MachineProductReport-getList')){
-                    if(array_key_exists($req['cpmc'].'-'.$req['page'].'-'.$req['limit'] , cache('MachineProductReport-getList'))){
-                        $rows = cache('MachineProductReport-getList')[$req['cpmc'].'-'.$req['page'].'-'.$req['limit']];
-                    }else{
-                        $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                                    a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                                    a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                                    a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                                    d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                                    rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type 
-                                FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                        $sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
-                        $sql .= 'UNION ALL
-                                SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                                    a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                                    a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                                    a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                                    d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
-                                    rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type 
-                                FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                        $sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
-                        $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
-                        $rows = db()->query($sql);
-
-                        //设置缓存
-                        $cache = cache('MachineProductReport-getList');
-                        $cache[$req['cpmc'].'-'.$req['page'].'-'.$req['limit']] = $rows;
-                        cache('MachineProductReport-getList',$cache,3600);
-                    }
-                }else{
-                    $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                                a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                                a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                                a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                                d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                                rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type 
-                            FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                    $sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
-                    $sql .= 'UNION ALL
-                            SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                                a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                                a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                                a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                                d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
-                                rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type 
-                            FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-                    $sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
-                    $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
-                    $rows = db()->query($sql);
-
-                    //设置缓存
-                    $cache = [];
-                    $cache[$req['cpmc'].'-'.$req['page'].'-'.$req['limit']] = $rows;
-                    cache('MachineProductReport-getList',$cache,3600);
-                }
-            }else{
-                $this->error('参数错误');
-            }
-        }
-
-        $gd = db('工单_基本资料')->column('Gd_gdbh, 成品名称 as Gd_cpmc');
-        $rs = db('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value){
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['Gd_cpmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? trim($gd[$value['sczl_gdbh']]) : '';
-            $rows[$key]['name1'] = array_key_exists($value['sczl_bh1'],$rs) ? trim($rs[$value['sczl_bh1']]) : '';
-            for ($i=2;$i<=6;$i++){
-                if ($value['sczl_bh'.$i]){
-                    if ($value['sczl_bh'.$i]==$value['sczl_bh1']){
-                        $rows[$key]['name'.$i] = $rows[$key]['name1'];
-                    }else{
-                        $rows[$key]['name'.$i] = array_key_exists($value['sczl_bh'.$i],$rs) ? trim($rs[$value['sczl_bh'.$i]]) : '';
-                    }
-                }else{
-                    $rows[$key]['name'.$i] = '';
-                }
-            }
-            $rows[$key]['jyno_gxmc'] = sprintf("%02d", $value['sczl_yjno']).'-'.sprintf("%02d", $value['sczl_gxh']).'-->'.trim($value['sczl_type']);
-            $rows[$key]['sczl_num'] = $value['sczl_num'] == 0 ? '' : $value['sczl_num'];
-            $rows[$key]['sczl_cl'] = $value['sczl_cl'] == 0 ? '' : floatval($value['sczl_cl']);
-            $rows[$key]['sczl_ms'] = $value['sczl_ms'] == 0 ? 1 : floatval($value['sczl_ms']);
-            $rows[$key]['sczl_zcfp'] = $value['sczl_zcfp'] == 0 ? '' : floatval($value['sczl_zcfp']);
-            $rows[$key]['sczl_zccp'] = $value['sczl_zccp'] == 0 ? '' : floatval($value['sczl_zccp']);
-            $rows[$key]['sczl_装版工时'] = $value['sczl_装版工时'] == 0 ? '' : floatval($value['sczl_装版工时']);
-            $rows[$key]['sczl_保养工时'] = $value['sczl_保养工时'] == 0 ? '' : floatval($value['sczl_保养工时']);
-            $rows[$key]['sczl_打样工时'] = $value['sczl_打样工时'] == 0 ? '' : floatval($value['sczl_打样工时']);
-            $rows[$key]['sczl_异常停机工时'] = $value['sczl_异常停机工时'] == 0 ? '' : floatval($value['sczl_异常停机工时']);
-            $rows[$key]['sczl_设备运行工时'] = $value['sczl_设备运行工时'] == 0 ? '' : floatval($value['sczl_设备运行工时']);
-            $rows[$key]['sczl_工价系数'] = $value['sczl_工价系数'] == 0 ? '' : floatval($value['sczl_工价系数']);
-            $rows[$key]['千件工价'] = $value['千件工价'] == 0 ? '' : floatval($value['千件工价']);
-            $rows[$key]['sczl_来料少数'] = $value['sczl_来料少数'] == 0 ? '' : floatval($value['sczl_来料少数']);
-            $rows[$key]['拆片联拼系数'] = $value['拆片联拼系数'] == 0 ? '' : floatval($value['拆片联拼系数']);
-            $rows[$key]['拆片条小盒系数'] = $value['拆片条小盒系数'] == 0 ? '' : floatval($value['拆片条小盒系数']);
-
-            unset($rows[$key]['sczl_yjno']);
-            unset($rows[$key]['sczl_gxh']);
-            unset($rows[$key]['sczl_type']);
-        }
-
-        $data = [
-            'total'         => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取机台生产日报表信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db('db_sczl')->alias('a')
-            ->field('a.sczl_gdbh, rtrim(j.成品名称) as Gd_cpmc, 
-            a.sczl_yjno, rtrim(y.yj_yjmc) as yj_yjmc, 
-            rtrim(a.sczl_gxmc) as sczl_gxmc, a.sczl_gxh, rtrim(a.sczl_type) as sczl_type, 
-            LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, a.sczl_bzdh, 
-            a.sczl_ms, a.sczl_ls, a.sczl_cl, a.sczl_fp as sczl_zcfp, 
-            a.sczl_装版总工时, a.sczl_装版工时, a.sczl_保养工时, a.sczl_异常停机工时, 
-            a.sczl_打样总工时, a.sczl_打样工时, a.sczl_设备运行工时, 
-            a.拆片联拼系数, a.拆片条小盒系数, 
-            a.sczl_dedh, a.sczl_工价系数, a.sczl_计产系数, 
-            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
-            ')
-            ->where('a.UniqId', $UniqId)
-            ->where('a.sczl_yjno = y.yj_Yjno')
-            ->join(['工单_基本资料'=>'j'],'a.sczl_gdbh = j.Gd_gdbh')
-            ->join(['工单_印件资料'=>'y'],'a.sczl_gdbh = y.Yj_Gdbh')
-            ->find();
-        $rs = db('人事_基本资料')->column('员工编号, 员工姓名');
-        for($i=1;$i<=10;$i++){
-            if(trim($rows['sczl_bh'.$i])!=''){
-                $rows['sczl_bh'.$i.'_name'] = array_key_exists($rows['sczl_bh'.$i],$rs) ? trim($rs[$rows['sczl_bh'.$i]]) : '';
-            }else{
-                $rows['sczl_bh'.$i.'_name'] = '';
-            }
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取工单名称
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     */
-    public function getGdmc()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $row = db('工单_基本资料')
-            ->field('rtrim(成品名称) as Gd_cpmc')
-            ->where('Gd_gdbh',$gdbh)
-            ->find();
-        $yjno= db('工单_工艺资料')
-            ->where(['Gy0_gdbh'=>$gdbh])
-            ->column('distinct Gy0_yjno');
-        $row['yjno'] = $yjno;
-        if (!$row) $this->error('查无此编号的工单, 请仔细检查后重新输入!');
-        $this->success('成功',$row);
-    }
-
-    /**
-     * 获取印件名称
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $yjno 印件号
-     */
-    public function getYjmc()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['yjno']) && !empty($req['yjno'])){
-            $yjno = $req['yjno'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $row = db('工单_印件资料')
-            ->field('rtrim(yj_yjmc) as yj_yjmc,yj_ls as sczl_ls')
-            ->where(['Yj_Gdbh'=>$gdbh,'yj_Yjno'=>$yjno])
-            ->find();
-        $gxmc = db('工单_工艺资料')
-        ->field('Gy0_gxh as sczl_gxh, rtrim(Gy0_gxmc) as sczl_type, rtrim(Add_gxmc) as Add_gxmc, Gy0_ms as sczl_ms')
-        ->where(['Gy0_gdbh'=>$gdbh,'Gy0_yjno'=>$yjno])
-        ->find();
-        if($gxmc['Add_gxmc'] != ''){
-            $gxmc['sczl_gxmc'] = sprintf("%02d", $gxmc['sczl_gxh']).'-'.$gxmc['Add_gxmc'];
-        }else{
-            $gxmc['sczl_gxmc'] = sprintf("%02d", $gxmc['sczl_gxh']).'-'.$gxmc['sczl_type'];
-        }
-        $gxmc['sczl_ls'] = $row['sczl_ls'];
-        unset($gxmc['Add_gxmc']);
-        $row['gxmc'] = $gxmc;
-        if (!$row) $this->error('印件编号不存在, 将恢复默认值, 请仔细确认数据准确性!');
-        $this->success('成功',$row);
-    }
-
-    /**
-     * 获取工序
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $yjno 印件号
-     * @param string $keyword 关键词
-     */
-    public function getGx()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['yjno']) && !empty($req['yjno'])){
-            $yjno = $req['yjno'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['keyword']) && !empty($req['keyword'])){
-            $keyword = $req['keyword'];
-        }else{
-            $keyword = '';
-        }
-
-        $rows = db('工单_工艺资料')
-            ->field('Gy0_gxh as sczl_gxh, rtrim(Gy0_gxmc) as sczl_type, rtrim(Add_gxmc) as Add_gxmc,Gy0_ls as sczl_ls, Gy0_ms as sczl_ms')
-            ->where(['Gy0_gdbh'=>$gdbh,'Gy0_yjno'=>$yjno])
-            ->where('Gy0_gxh|Gy0_gxmc|Add_gxmc','like','%'.$keyword.'%')
-            ->select();
-        foreach ($rows as $key=>$value) {
-            if($value['Add_gxmc'] != ''){
-                $rows[$key]['sczl_gxmc'] = sprintf("%02d", $value['sczl_gxh']).'-'.$value['Add_gxmc'];
-            }else{
-                $rows[$key]['sczl_gxmc'] = sprintf("%02d", $value['sczl_gxh']).'-'.$value['sczl_type'];
-            }
-            unset($rows[$key]['Add_gxmc']);
-        }
-        if (!$rows) $this->error('失败');
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询机台
-     * @ApiMethod (GET)
-     */
-    public function getJtbh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['sczl_type']) && !empty($req['sczl_type'])){
-            $sczl_type = $req['sczl_type'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['key_word'])){
-            $key_word = $req['key_word'];
-        }else{
-            $this->error('参数错误');
-        }
-        $rows = db('设备_基本资料')
-            ->field('rtrim(设备编号) as jtbh, rtrim(设备名称) as 设备名称')
-            ->where('设备编号|设备名称','like','%'.$key_word.'%')
-            ->where('生产工序','like','%'.$sczl_type.'%')
-            ->order('设备编号 asc')
-            ->select();
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询定额代号
-     * @ApiMethod (GET)
-     */
-    public function getDedh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (!isset($req['sczl_jtbh'])){
-            $this->error('参数错误');
-        }
-        if(!empty($req['sczl_jtbh'])){
-            $row = db('dic_lzde')
-            ->field('sys_bh')
-            ->where('适用机型',$req['sczl_jtbh'])
-            ->find();
-            $this->success('成功',$row);
-        }
-
-        $row = db('dic_lzde')
-            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
-            ->where('sys_mc','人工作业计件定额')
-            ->find();
-        $rows = db('dic_lzde')
-            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
-            ->where('Parent',$row['Key_'])
-            ->order('sys_bh asc')
-            ->select();
-        foreach ($rows as $key=>$value){
-            $bool = db('dic_lzde')
-                ->field('Key_,sys_bh, rtrim(sys_mc) as sys_mc')
-                ->where('Parent',$value['Key_'])
-                ->order('sys_bh asc')
-                ->select();
-            if ($bool){
-                foreach ($bool as $k=>$v){
-                    $bool1 = db('dic_lzde')
-                        ->field('sys_bh, rtrim(sys_mc) as sys_mc')
-                        ->where('Parent',$v['Key_'])
-                        ->order('sys_bh asc')
-                        ->select();
-
-                    if ($bool1){
-                        $bool[$k]['bh_mc'] = $bool1;
-                    }
-                }
-                $rows[$key]['bh_mc'] = $bool;
-            }
-        }
-        $row['bh_mc'] = $rows;
-
-        $this->success('成功',$row);
-    }
-
-    /**
-     * 定额代号查询比例
-     * @ApiMethod (GET)
-     */
-    public function dedhGetRate()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (!(isset($req['dedh'])) || empty($req['dedh'])){
-            $this->error('参数错误');
-        }
-        $row = db('dic_lzde')
-            ->field('机长比例 as sczl_rate1, 副机比例 as sczl_rate2, 调墨比例 as sczl_rate3, 二手比例 as sczl_rate4, 飞达比例 as sczl_rate5, 
-            辅助比例 as sczl_rate6, 放卷比例 as sczl_rate7, 分切1比例 as sczl_rate8, 分切2比例 as sczl_rate9, 检验比例 as sczl_rate10')
-            ->where('sys_bh',$req['dedh'])
-            ->find();
-
-        $this->success('成功',$row);
-    }
-            
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string
-     */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sys_id','sczl_gdbh','sczl_yjno',
-            'sczl_gxmc','sczl_gxh','sczl_type',
-            'sczl_rq','sczl_jtbh','sczl_bzdh',
-            'sczl_ms','sczl_ls','sczl_cl','sczl_fp',
-            'sczl_装版总工时','sczl_装版工时','sczl_保养工时','sczl_异常停机工时',
-            'sczl_打样总工时','sczl_打样工时','sczl_设备运行工时',
-            '拆片联拼系数','拆片条小盒系数','sczl_dedh','sczl_工价系数','sczl_计产系数',
-            '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'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!(isset($req[$value]))){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['sys_rq'] = date('Y-m-d H:i:s');
-
-        //查询UniqId
-        $UniqId = db('db_sczl')->max('UniqId');
-        $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('db_sczl')->fetchSql(true)->insert($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-            cache('MachineProductReport-getList',null);
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string
-     */
-    public function edit()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'UniqId','sczl_gdbh','sczl_yjno',
-            'sczl_gxmc','sczl_gxh','sczl_type',
-            'sczl_rq','sczl_jtbh','sczl_bzdh',
-            'sczl_ms','sczl_ls','sczl_cl','sczl_fp',
-            'sczl_装版总工时','sczl_装版工时','sczl_保养工时','sczl_异常停机工时',
-            'sczl_打样总工时','sczl_打样工时','sczl_设备运行工时',
-            '拆片联拼系数','拆片条小盒系数','sczl_dedh','sczl_工价系数','sczl_计产系数',
-            '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'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!(isset($req[$value]))){
-                continue;
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['mod_rq'] = date('Y-m-d H:i:s');
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('db_sczl')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-            cache('MachineProductReport-getList',null);
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId'
-     */
-    public function del()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db('db_sczl')->where('UniqId',$req['UniqId'])->delete();
-            // 提交事务
-            db()->commit();
-            cache('MachineProductReport-getList',null);
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 工序汇总导出
-     * @ApiMethod (GET)
-     * @param string date
-     * @param string sys_id
-     * @param array fields
-     */
-    public function export(){
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $where = [];
-        if (!isset($req['date']) || empty($req['date'])) $this->error('参数缺失');
-
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-
-        $arr = [
-            'sczl_gdbh'          =>['工单编号'],
-            'Gd_cpmc'            =>['产品名称'],
-            'jyno_gxmc'          =>['印件及工序'],
-            'sczl_rq'            =>['生产日期'],
-            'sczl_jtbh'          =>['机台'],
-            'sczl_bzdh'          =>['班组'],
-            'sczl_num'           =>['流程单'],
-            'sczl_cl'            =>['车头产量'],
-            'sczl_ms'            =>['色度数'],
-            'sczl_zcfp'          =>['制程废'],
-            'sczl_zccp'          =>['次品'],
-            'sczl_来料异常'      =>['来料异常'],
-            'sczl_装版工时'      =>['装版工时'],
-            'sczl_保养工时'      =>['保养工时'],
-            'sczl_打样工时'      =>['打样工时'],
-            'sczl_异常停机工时'  =>['异常停机工时'],
-            'sczl_设备运行工时'  =>['设备运行工时'],
-            'sczl_bh1'           =>['组员编号1'],
-            'sczl_bh1_name'      =>['组员姓名1'],
-            'sczl_bh2'           =>['组员编号2'],
-            'sczl_bh2_name'      =>['组员姓名2'],
-            'sczl_bh3'           =>['组员编号3'],
-            'sczl_bh3_name'      =>['组员姓名3'],
-            'sczl_bh4'           =>['组员编号4'],
-            'sczl_bh4_name'      =>['组员姓名4'],
-            'sczl_bh5'           =>['组员编号5'],
-            'sczl_bh5_name'      =>['组员姓名5'],
-            'sczl_bh6'           =>['组员编号6'],
-            'sczl_bh6_name'      =>['组员姓名6'],
-            '拆片联拼系数'       =>['拆片联拼系数'],
-            '拆片条小盒系数'     =>['拆片条小盒系数'],
-            'sczl_工价系数'      =>['工价系数'],
-            '日定额'             =>['日定额'],
-            '千件工价'           =>['千件工价'],
-            '补产标准'           =>['补产标准'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        // UNION 查询两表数据
-        // db_sczl缺少数据 --> a.sczl_来料少数,
-        // 设备_产量计酬缺少数据 --> a.拆片联拼系数, a.拆片条小盒系数,
-        $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh, 
-                    a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
-                    a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时, 
-                    a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                    d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数 as sczl_来料异常, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数, 
-                    rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
-                FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
-        $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
-        $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` LIKE "'.$req['sys_id'].'%" ' : '';
-        $sql .= 'UNION ALL
-                SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
-                    a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
-                    a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
-                    a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数, 
-                    d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料异常, a.拆片联拼系数, a.拆片条小盒系数,
-                    rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
-                FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
-        $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
-        $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` LIKE "'.$req['sys_id'].'%" ' : '';
-        $sql .= 'ORDER BY sys_id ASC, sczl_num ASC';
-        $rows = db()->query($sql);
-
-        $gd = db('工单_基本资料')->column('Gd_gdbh, 成品名称 as Gd_cpmc');
-        $rs = db('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value){
-            $subArray = [];
-            foreach ($arr as $k=>$v){
-                if($k=='sczl_来料异常' || $k=='拆片联拼系数' || $k=='拆片条小盒系数'){
-                    $subArray[$k] = $value[$k] == null ? '' : floatval($value[$k]);
-                }else if($k=='Gd_cpmc'){
-                    if(trim($value['sczl_gdbh']) != '' && array_key_exists($value['sczl_gdbh'],$gd)){
-                        $subArray[$k] = trim($gd[$value['sczl_gdbh']]);
-                    }else{
-                        $subArray[$k] = '';
-                    }
-                }else if($k=='sczl_bh1_name' || $k=='sczl_bh2_name' || $k=='sczl_bh3_name' || $k=='sczl_bh4_name' || $k=='sczl_bh5_name' || $k=='sczl_bh6_name'){
-                    if(trim($value[substr($k,0,8)]) != '' && array_key_exists($value[substr($k,0,8)],$rs)){
-                        $subArray[$k] = trim($rs[$value[substr($k,0,8)]]);
-                    }else{
-                        $subArray[$k] = '';
-                    }
-                }else if($k=='sczl_num' || $k=='sczl_cl' || $k=='sczl_zcfp' || $k=='sczl_zccp' || $k=='sczl_装版工时' || $k=='sczl_保养工时' || $k=='sczl_打样工时' ||
-                    $k=='sczl_异常停机工时' || $k=='sczl_设备运行工时' || $k=='拆片联拼系数' || $k=='拆片条小盒系数' || $k=='sczl_工价系数' || $k=='千件工价'){
-                    $subArray[$k] = $value[$k] == 0 ? '' : floatval($value[$k]);
-                }else if($k=='sczl_ms'){
-                    $subArray[$k] = $value[$k] == 0 ? 1 : floatval($value[$k]);
-                }else if($k=='jyno_gxmc'){
-                    $subArray['jyno_gxmc'] = sprintf("%02d", $value['sczl_yjno']).'-'.sprintf("%02d", $value['sczl_gxh']).'-->'.trim($value['sczl_type']);
-                }else{
-                    $subArray[$k] = $rows[$key][$k];
-                }
-            }
-            array_push($data,$subArray);
-        }
-
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-}

+ 0 - 385
application/api/controller/MachineProductionReportAdd.php

@@ -1,385 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-
-/**
- * 机台生产日报表维护附加接口
- */
-class MachineProductionReportAdd extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取机台生产日报表附加侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-
-        $rows = db('db_sczladd')
-            ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
-            ->group('date')
-            ->order('UniqId desc')
-            ->limit(60)
-            ->select();
-        $arr = db('db_sczladd')
-            ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(*) as count')
-            ->where('sys_rq','>=',$rows[count($rows)-1]['date'])
-            ->group('date, sys_id')
-            ->select();
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['sys'] = [];
-            foreach($arr as $k=>$v){
-                if($value['date'] == $v['date']){
-                    unset($v['date']);
-                    array_push($rows[$key]['sys'],$v);
-                    unset($arr[$k]);
-                }
-            }
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取机台生产日报表附加列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['sys_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE',$req['sys_id'].'%'];
-
-        //来料异常 日定额 千件工价 补产标准
-        //制程废 次品
-        $rows = db('db_sczladd')
-            ->field('LEFT(sczl_rq, 10) as sczl_rq, sczl_jtbh, 
-            sczl_bzdh, CAST(sczl_设备运行工时 AS SIGNED) as sczl_设备运行工时, sczl_desc, 
-            rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
-            ->where($where)
-            ->order('UniqId desc')
-            ->page($page,$limit)
-            ->select();
-        $total = db('db_sczladd')->where($where)->count();
-
-        $sb = db('设备_基本资料')->column('设备编号, 设备名称');
-        foreach ($rows as $key=>$value){
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['sczl_sbmc'] = trim($sb[$value['sczl_jtbh']]);
-            $rows[$key]['sczl_设备运行工时'] = $value['sczl_设备运行工时'] == 0 ? '' : $value['sczl_设备运行工时'];
-        }
-
-        $data = [
-            'total'          => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取机台生产日报表附加信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db('db_sczladd')->alias('d')
-            ->field('LEFT(d.sczl_rq, 10) as sczl_rq, d.sczl_jtbh, rtrim(g.设备名称) as 设备名称, d.sczl_bzdh, d.sczl_设备运行工时, d.sczl_desc')
-            ->join('设备_基本资料 g', 'd.sczl_jtbh=g.设备编号')
-            ->where('d.UniqId',$UniqId)
-            ->select();
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询机台
-     * @ApiMethod (GET)
-     */
-    public function getJtbh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['sys_mc'])){
-            $sys_mc = $req['sys_mc'];
-        }else{
-            $this->error('参数错误');
-        }
-        $rows = db('设备_基本资料')
-            ->field('rtrim(使用部门) as 使用部门, rtrim(设备编号) as jtbh, rtrim(设备名称) as 设备名称')
-            ->where('设备编号|设备名称','like','%'.$sys_mc.'%')
-            ->order('设备编号 asc')
-            ->select();
-        $arr = array_unique(array_column($rows, '使用部门'));
-        sort($arr);
-        $data = [];
-        $data['使用部门'] = [];
-        foreach ($arr as $value) {
-            $data[$value] = [];
-            foreach ($rows as $row){
-                if($row['使用部门']==$value){
-                    if (!in_array($row['使用部门'], $data['使用部门'])) {
-                        array_push($data['使用部门'],$row['使用部门']);
-                    }
-                    unset($row['使用部门']);
-                    array_push($data[$value], $row);
-                }
-            }
-        }
-        $this->success('成功',[$data]);
-    }
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string
-     */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sys_id','sczl_rq','sczl_jtbh',
-            'sczl_bzdh','sczl_设备运行工时',
-            'sczl_desc'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!(isset($req[$value]))){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['sys_rq'] = date('Y-m-d H:i:s');
-
-        //查询UniqId
-        $UniqId = db('db_sczladd')->max('UniqId');
-        $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('db_sczladd')->fetchSql(true)->insert($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string
-     */
-    public function edit()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sys_id','sczl_rq','sczl_jtbh',
-            'sczl_bzdh','sczl_设备运行工时',
-            'sczl_desc'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!(isset($req[$value]))){
-                continue;
-            }
-            $data[$value] = $req[$value];
-        }
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-        $data['mod_rq'] = date('Y-m-d H:i:s');
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('db_sczladd')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId'
-     */
-    public function del()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db('db_sczladd')->where('UniqId',$req['UniqId'])->delete();
-
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * excel导出
-     * @ApiMethod (GET)
-     * @param string file_name
-     * @param string date
-     * @param string sys_id
-     * @param array fields
-     */
-    public function export(){
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $where = [];
-        if (!isset($req['date']) || empty($req['date'])) $this->error('参数缺失');
-
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-        if(strpos($req['date'],'-')){
-            $where = ['a.sys_rq'=>['like',$req['date'].'%']];
-        }else{
-            $where = ['a.sczl_gdbh'=>$req['date']];
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])){
-            $where['a.sys_id'] = ['LIKE',$req['sys_id'].'%'];
-        }
-
-
-        $field = '';
-        $arr = [
-            'sczl_rq'           =>['生产日期','LEFT(a.sczl_rq, 10) as sczl_rq'],
-            'sczl_jtbh'         =>['设备编号','a.sczl_jtbh'],
-            '设备名称'           =>['设备名称','rtrim(b.设备名称) as 设备名称'],
-            'sczl_bzdh'         =>['班组','rtrim(a.sczl_bzdh) as sczl_bzdh'],
-            'sczl_设备运行工时'  =>['排班工时','a.sczl_设备运行工时'],
-            'sczl_desc'         =>['备注','rtrim(a.sczl_desc) as sczl_desc']
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                if ($k==0){
-                    $field .= $arr[$v][1];
-                }else{
-                    $field .= ','.$arr[$v][1];
-                }
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        $rows = db('db_sczladd')->alias('a')
-            ->join('设备_基本资料 b','a.sczl_jtbh = b.设备编号','left')
-            ->field($field)
-            ->where($where)
-            ->order('a.UniqId asc')
-            ->select();
-
-        foreach ($rows as $key=>$value) {
-            if (isset($value['sczl_设备运行工时'])) $value['sczl_设备运行工时'] = floatval($value['sczl_设备运行工时']);
-            $subArray = [];
-            foreach ($req['fields'] as $k=>$v){
-                if(array_key_exists($v,$arr)){
-                    if($value[$v]){
-                        array_push($subArray,$value[$v]);
-                    }else{
-                        array_push($subArray,'');
-                    }
-                }
-            }
-            array_push($data,$subArray);
-        }
-        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-}

+ 0 - 378
application/api/controller/OtherCountDocument.php

@@ -1,378 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use \think\Request;
-use \think\Db;
-/**
- * 其他计件单据维护接口
- */
-class OtherCountDocument extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取其他计件单据侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-//        $rows = db()->table('db_拉料计件')
-//            ->field('LEFT(Sczl_rq, 7) as date, CAST(sum(Sczl_cl) AS SIGNED) as counts')
-//            ->group('LEFT(Sczl_rq, 7)')
-//            ->order('UniqId desc')
-//            ->paginate(13);
-//halt($rows);
-//        $rows->each(function ($item){
-//            $arr = db()->table('db_拉料计件')->alias('l')
-//                ->field('rtrim(l.Sczl_bh1) as Sczl_bh1, rtrim(r.员工姓名) as name, sum(l.Sczl_cl) as count')
-//                ->where('l.sczl_rq','LIKE',$item['date'].'%')
-//                ->join(['人事_基本资料'=>'r'],'l.Sczl_bh1 = r.员工编号')
-//                ->group('Sczl_bh1')
-//                ->select();
-//
-//            $item['sys']=$arr;
-//        });
-//        halt($rows);
-        $rows = db()->table('db_拉料计件')
-            ->field('LEFT(Sczl_rq, 7) as date, CAST(sum(Sczl_cl) AS SIGNED) as counts')
-            ->group('date')
-            ->order('UniqId desc')
-            ->limit(13)
-            ->select();
-//        halt($rows);
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach($rows as $key=>$value){
-            $arr = db()->table('db_拉料计件')
-                ->field('rtrim(Sczl_bh1) as Sczl_bh1, CAST(sum(Sczl_cl) AS SIGNED) as count')
-                ->where('sczl_rq','LIKE',$value['date'].'%')
-                ->group('Sczl_bh1')
-                ->select();
-
-            foreach ($arr as $k=>$v) {
-                $arr[$k]['name'] = array_key_exists($v['Sczl_bh1'],$rs) ? trim($rs[$v['Sczl_bh1']]) : '';
-            }
-
-            $rows[$key]['sys'] = $arr;
-            $rows[$key]['date'] = str_replace('-', '', $rows[$key]['date']);
-        }
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取其他计件单据列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $Sczl_bh1 员工编号
-     * @param string $order 工单编号
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['a.Sczl_rq'] = ['LIKE',$req['date'].'%'];
-        }
-        if (!empty($req['order']) && (!empty($req['date']) || !empty($req['Sczl_bh1']))){
-            $this->error('参数错误');
-        }
-        if (isset($req['Sczl_bh1']) && !empty($req['Sczl_bh1'])) $where['a.Sczl_bh1'] = $req['Sczl_bh1'];
-        if (isset($req['order']) && !empty($req['order'])) $where['a.Sczl_gdbh'] = $req['order'];
-
-        $rows = db()->table('db_拉料计件')->alias('a')
-            ->join('dic_lzde b','a.Sczl_dedh = b.sys_bh','left')
-            ->field('rtrim(a.sczl_Type) as sczl_Type, LEFT(a.Sczl_rq, 10) as Sczl_rq, a.Sczl_bh1, a.sczl_gdbh, CAST(a.Sczl_cl AS SIGNED) as Sczl_cl,
-            rtrim(a.Sczl_desc) as Sczl_desc, rtrim(a.Sczl_gxmc) as Sczl_gxmc, a.sczl_yjno, a.sczl_gxh, rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId,b.sys_bh,rtrim(sys_mc) as sys_mc')
-            ->where($where)
-            ->page($page,$limit)
-            ->order('a.Sczl_rq asc, a.UniqId asc')
-            ->select();
-
-        $total = db()->table('db_拉料计件')->alias('a')
-            ->join('dic_lzde b','a.Sczl_dedh = b.sys_bh','left')
-            ->where($where)->count();
-        $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value) {
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['Gd_cpmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? trim($gd[$value['sczl_gdbh']]) : '';
-            $rows[$key]['name'] = array_key_exists($value['Sczl_bh1'],$rs) ? trim($rs[$value['Sczl_bh1']]) : '';
-        }
-
-        $data = [
-            'total'         => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取其他计件单据信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db()->table('db_拉料计件')->alias('a')
-            ->field('a.*,rtrim(d.员工姓名) as name,rtrim(c.sys_mc) as sys_mc,rtrim(b.成品名称) as product_name')
-            ->join('人事_基本资料 d', 'a.Sczl_bh1 = d.员工编号','left')
-            ->join('工单_基本资料 b', 'a.Sczl_gdbh = b.Gd_gdbh','left')
-            ->join('dic_lzde c', 'a.Sczl_dedh = c.sys_bh','left')
-            ->where('a.UniqId',$UniqId)
-            ->select();
-
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询印件工序及产品名称
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $gxmc 工序名称
-     */
-    public function getGxMc()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['keyword']) && !empty($req['keyword'])){
-            $keyword = $req['keyword'];
-        }else{
-            $keyword = '';
-        }
-        $rows = db()->table('工单_印件资料')->alias('g')
-            ->field('rtrim(g.yj_yjmc) as Gd_cpmc, g.yj_Yjno as Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc, rtrim(c.Add_gxmc) as Add_gxmc')
-            ->where(['g.Yj_Gdbh' => $gdbh])
-            ->where(function ($query) use ($keyword) {
-                $query->where(function ($query) use ($keyword) {
-                    $query->where('c.Gy0_yjno', 'like', '%' . $keyword . '%')
-                        ->whereOr('c.Gy0_gxh', 'like', '%' . $keyword . '%')
-                        ->whereOr('c.Add_gxmc', 'like', '%' . $keyword . '%');
-                });
-                $query->whereOr(function ($query) use ($keyword) {
-                    $query->where('c.Add_gxmc', '=', '')
-                        ->where(function ($query) use ($keyword) {
-                            $query->where('c.Gy0_yjno', 'like', '%' . $keyword . '%')
-                                ->whereOr('c.Gy0_gxh', 'like', '%' . $keyword . '%')
-                                ->whereOr('c.Gy0_gxmc', 'like', '%' . $keyword . '%');
-                        });
-                });
-            })
-            ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Yj_Gdbh and g.yj_Yjno=c.Gy0_yjno')
-            ->select();
-
-
-        foreach ($rows as $key=>$value){
-            if($value['Add_gxmc'] != ''){
-                $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.sprintf("%02d", $value['Gy0_gxh']).'-'.$value['Add_gxmc'];
-            }else{
-                $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.sprintf("%02d", $value['Gy0_gxh']).'-'.$value['Gy0_gxmc'];
-            }
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询定额代号
-     * @ApiMethod (GET)
-     */
-    public function getDedh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-
-        $row = db('dic_lzde')
-            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
-            ->where('sys_mc','包装')
-            ->find();
-        $rows = db('dic_lzde')
-            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
-            ->where('Parent',$row['Key_'])
-            ->order('sys_bh asc')
-            ->select();
-        foreach ($rows as $key=>$value){
-            $bool = db('dic_lzde')
-                ->field('Key_,sys_bh, rtrim(sys_mc) as sys_mc')
-                ->where('Parent',$value['Key_'])
-                ->order('sys_bh asc')
-                ->select();
-            if ($bool){
-                foreach ($bool as $k=>$v){
-                    $bool1 = db('dic_lzde')
-                        ->field('sys_bh, rtrim(sys_mc) as sys_mc')
-                        ->where('Parent',$v['Key_'])
-                        ->order('sys_bh asc')
-                        ->select();
-
-                    if ($bool1){
-                        $bool[$k]['bh_mc'] = $bool1;
-                    }
-                }
-                $rows[$key]['bh_mc'] = $bool;
-            }
-        }
-        $row['bh_mc'] = $rows;
-
-        $this->success('成功',$row);
-    }
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string
-     */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'Sys_id',
-            'Sczl_bh1',
-            'sczl_Type',
-            'Sczl_rq',
-            'Sczl_gdbh',
-            'Sczl_gxmc',
-            'sczl_gxh',
-            'Sczl_cl',
-            'Sczl_dedh',
-            'Sczl_desc',
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['Sys_rq'] = date('Y-m-d H:i:s');
-
-        //查询UniqId
-        $UniqId = db()->table('db_拉料计件')->max('UniqId');
-        $data['UniqId'] = $UniqId+1;
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db()->table('db_拉料计件')->fetchSql(true)->insert($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 拉料计件产量维护修改
-     * @ApiMethod POST
-     * @params array data
-    */
-    public function edit(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        if (!isset($params) || !isset($params['UniqId'])){
-            $this->error('参数不能为空');
-        }
-        $uniqId = $params['UniqId'];
-        unset($params['UniqId']);
-        $sql = Db::name('db_拉料计件')->where('UniqId',$uniqId)->fetchSql(true)->update($params);
-        $res = Db::query($sql);
-        if ($res !== false){
-            $this->success('更新成功');
-        }else{
-            $this->error('更新失败');
-        }
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId'
-     */
-    public function del()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db()->table('db_拉料计件')->where('UniqId',$req['UniqId'])->delete();
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-}

+ 0 - 450
application/api/controller/OvertimeVerification.php

@@ -1,450 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use \think\Request;
-use \think\Db;
-/**
- * 计件员工加班费核查接口
- */
-class OvertimeVerification extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 计件员工加班费核查侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $res=db('绩效工资汇总')
-            ->field('DATE_FORMAT(`sczl_rq`, "%Y%m") as sys_ny,bh')
-            ->group('DATE_FORMAT(`sczl_rq`, "%Y%m"),bh')
-            ->whereTime('sczl_rq', '>=', strtotime('-14 months'))
-            ->where('bh','<>','000000')
-            ->order('sczl_rq desc')
-            ->select();
-        foreach($res as $v){
-            $arr[$v['sys_ny'].'('][]=$v['bh'];
-        }
-        $rs = db('人事_基本资料')->column('员工编号,所在部门');
-        foreach($arr as $k=>$v){
-            foreach($v as $value){
-                if(array_key_exists($value,$rs)){
-                    $data[$k.count($v).'人)'][rtrim($rs[$value])][]=rtrim($rs[$value]);
-                }            }
-            $j=0;
-            foreach($data[$k.count($v).'人)'] as $keys=>$values){
-                $data[$k.count($v).'人)']['bm'][$j]=$keys;
-                $data[$k.count($v).'人)'][$keys]=count($values);
-                $j++;
-            }
-            usort($data[$k.count($v).'人)']['bm'], function($a, $b) {
-                $order = array(
-                    '胶印车间',
-                    '凹印车间',
-                    '丝印车间',
-                    '模切车间',
-                    '检验车间',
-                    '精品试验车间',
-                    '品保部',
-                    '人力资源部',
-                    '生产部',
-                    '营销部'
-                );
-                $a_index = array_search($a, $order);
-                $b_index = array_search($b, $order);
-                return $a_index - $b_index;
-            });
-            foreach($data[$k.count($v).'人)']['bm'] as &$va){
-                $va=$va.'('.$data[$k.count($v).'人)'][$va].'人)';
-            }
-            $data[$k.count($v).'人)']=$data[$k.count($v).'人)']['bm'];
-        }
-        $i=0;
-        foreach($data as $k=>$v){
-            $datas[$i]['label']=$k;
-            $gdbh=substr($k,0,strpos($k,'('));
-            foreach($v as $key=>$value){
-                $datas[$i]['children'][$key]['label']=$value;
-                $datas[$i]['children'][$key]['gdbh']=$gdbh;
-            }
-            $i++;
-        }
-        $this->success('成功',$datas);
-    }
-    
-
-    /**
-     * 计件员工加班费核查上侧列表
-     * @ApiMethod (GET)
-     * @param string $date 年月
-     * @param string $department 部门
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $res=db('绩效工资汇总')->alias('j')
-            ->join('人事_基本资料 r','r.员工编号=j.bh')
-            ->group('j.bh')
-            ->where('j.sys_ny',$req['date'])
-            ->where(['r.所在部门'=>['like',$req['department'].'%']])
-            ->column('CONCAT(j.bh, "-", DATE_FORMAT(j.sczl_rq,"%Y.%m")) AS rq_bh,j.bh,rtrim(j.xm) as 员工姓名,r.工资表类别,DATE_FORMAT(r.聘用日期,"%Y.%m.%d") as 聘用日期,j.法定天数,
-            sum(j.达标定额) as 当月定额,(sum(j.班组车头产量*j.工序难度系数)+sum(j.班组换算产量)) as 月度合计产量,sum(j.个人计件工资) as 个人计件工资,
-            sum(j.个人加班工资) as 个人加班工资,sum(j.异常停机工时) as 月计时时数,LEFT(j.sczl_rq, 7) as sczl_rq');
-
-        $year=substr($req['date'],0,4);
-        $month=substr($req['date'],-2);
-        $start_time = $year . '-' . $month . '-01 00:00:00';
-        $end_time = date('Y-m-t', strtotime("$year-$month-01")) . ' 23:59:59';
-        $arr = [];
-        $columns = ['wgjs_bh1', 'wgjs_bh2', 'wgjs_bh3', 'wgjs_bh4', 'wgjs_bh5', 'wgjs_bh6'];
-        for ($i = 1; $i <= 6; $i++) {
-            $column = $columns[$i-1];
-            $r = db('db_wgjs')
-                ->field("DATE_FORMAT(wgjs_rq,'%Y.%m') as wgjs_rq, $column as wgjs_bh, wgjs_js$i as wgjs_js, wgjs_冲定额$i as wgjs_冲定额")
-                ->join('人事_基本资料', "人事_基本资料.员工编号=db_wgjs.$column")
-                ->where(['wgjs_rq' => ['between', "$start_time,$end_time"], '人事_基本资料.所在部门' => ['like', $req['department'] . '%']])
-                ->select();
-
-            $arr = array_merge($arr, $r);
-        }
-
-        $list = [];
-        foreach($arr as $v){
-            if(isset($list[$v['wgjs_bh'].'-'.$v['wgjs_rq']])){
-                if($v['wgjs_冲定额']=='是'){
-                    $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']+=$v['wgjs_js'];
-                }
-            }else{
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['bh']=$v['wgjs_bh'];
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['sczl_rq']=$v['wgjs_rq'];
-                if($v['wgjs_冲定额']=='是'){
-                    $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=$v['wgjs_js'];
-                }else{
-                    $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=0;
-                }
-            }
-        };
-
-        //获取每个员工计时补差天数
-        $arr1 = db('绩效工资汇总')->alias('j')
-            ->field('j.bh,j.sczl_rq')
-            ->join('人事_基本资料 r','r.员工编号=j.bh')
-            ->group('j.bh,j.sczl_rq')
-            ->where('j.sys_ny',$req['date'])
-            // ->where('j.达标定额','<>',0)
-            ->where(['r.所在部门'=>['like',$req['department'].'%']])
-            ->buildSql();
-        $arr1 = db()->table($arr1 . ' t')
-            ->group('t.bh, LEFT(t.sczl_rq, 7)')
-            ->column('t.bh,count(LEFT(t.sczl_rq, 7)) as num');
-
-        //查询每条记录
-        $arr2 = db('绩效工资汇总')->alias('j')
-            ->field('j.bh, DATE_FORMAT(j.sczl_rq,"%Y.%m") as sczl_rq,
-            sum(j.达标定额) as 达标定额, j.Rate, j.千件工价')
-            ->join('人事_基本资料 r','r.员工编号=j.bh')
-            ->where('j.sys_ny',$req['date'])
-            // ->where('j.达标定额','<>',0)
-            ->where(['r.所在部门'=>['like',$req['department'].'%']])
-            ->group('j.bh,j.sczl_rq,j.sczl_gdbh')
-            ->select();
-        //计算每条记录的计时补差
-        $brr = [];
-        foreach($arr2 as $v){
-            $yjsss1 = array_key_exists($v['bh'].'-'.$v['sczl_rq'],$list) ? $list[$v['bh'].'-'.$v['sczl_rq']]['月计时时数'] : 0;
-            $yjsss2 = array_key_exists($v['bh'].'-'.$v['sczl_rq'],$res) ? $res[$v['bh'].'-'.$v['sczl_rq']]['月计时时数'] : 0;
-            $yjsss = $yjsss1 + $yjsss2;
-            $a = $yjsss/$arr1[$v['bh']]/11*0.6*$v['达标定额']*$v['Rate']*0.5/1000*$v['千件工价'];
-                
-            if(array_key_exists($v['bh'].'-'.$v['sczl_rq'],$brr)){
-                $brr[$v['bh'].'-'.$v['sczl_rq']] += $a;
-            }else{
-                $brr[$v['bh'].'-'.$v['sczl_rq']] = $a;
-            }
-        }
-
-        foreach($res as $k=>&$v){
-            if(array_key_exists($k,$list)){
-                $v['月计时时数'] += $list[$k]['月计时时数'];
-            }
-            $v['工资表类别'] = trim($v['工资表类别']);
-            $v['法定天数'] = round($v['法定天数']);
-            $v['当月定额'] = round($v['当月定额']);
-            $v['月度合计产量'] = round($v['月度合计产量']);
-            $v['月计时时数'] = floatval(number_format($v['月计时时数'],2, '.', ''));
-            $v['计时补差'] = floatval(number_format($brr[$k],2, '.', ''));
-            unset($v['rq_bh']);
-        }
-        $res = array_values($res);
-        $this->success('成功',$res);
-    }
-    /**
-     * 计件员工加班费核查下侧列表
-     * @ApiMethod (GET)
-     * @param string $date 年月
-     * @param string $code 员工编号
-     */
-    public function getAllList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $res=db('绩效工资汇总')
-            ->field('LEFT(sczl_rq, 10) as sczl_rq,sczl_gdbh,rtrim(g.yj_yjmc) as Gd_cpmc,sczl_yjno,sczl_gxh,sczl_type,
-            sczl_jtbh,sum(班组车头产量) as 班组车头产量,工序难度系数 as 产量系数,(sum(班组车头产量*工序难度系数)) as 计件产量,
-            sum(班组换算产量) as 补产产量,(sum(班组车头产量*工序难度系数)+sum(班组换算产量)) as 核算产量,日定额,sum(达标定额)
-            as 达标定额,千件工价,补产标准,sum(个人计件工资) as 个人计件工资,sum(个人加班工资) as 个人加班工资,Rate as 个人比例,
-            sum(装版工时) as 装版工时,sum(保养工时) as 保养工时,sum(打样工时) as 打样工时,sum(计时补差额工资) as 计时补差')
-            ->join('工单_印件资料 g','g.Yj_Gdbh = 绩效工资汇总.sczl_gdbh AND g.yj_Yjno = 绩效工资汇总.sczl_yjno','LEFT')
-            ->group('LEFT(sczl_rq, 10),sczl_gdbh,CONCAT(sczl_yjno, "-", sczl_gxh, "-", sczl_type)')
-            ->where(['sys_ny'=>$req['date'],'bh'=>$req['code']])
-            ->select();
-        if(!$res){
-            $this->error('失败');
-        }
-        foreach($res as &$v){
-            $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']);
-            if($v['sczl_yjno']>9){
-                $sczl_yjno=$v['sczl_yjno'];
-            }else{
-                $sczl_yjno='0'.$v['sczl_yjno'];
-            }
-            unset($v['sczl_yjno']);
-            if($v['sczl_gxh']>9){
-                $sczl_gxh=$v['sczl_gxh'];
-            }else{
-                $sczl_gxh='0'.$v['sczl_gxh'];
-            }
-            $v['计件产量'] = floatval(number_format($v['计件产量'], 2, '.', ''));
-            $v['核算产量'] = floatval(number_format($v['核算产量'], 2, '.', ''));
-            unset($v['sczl_gxh']);
-            $v['sczl_type']=$sczl_yjno.'-'.$sczl_gxh.'-->'.$v['sczl_type'];
-        }
-        $this->success('成功',$res);
-    }
-     /**
-     * 计件员工加班费核查详情
-     * @ApiMethod (GET)
-     * @param string $date 日期
-     * @param string $code 员工编号
-     */
-    public function getDetail()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $start_time=$req['date'].' 00:00:00';
-        $end_time=$req['date'].' 23:59:59';
-        $res=db('绩效工资汇总')
-           ->field('LEFT(sczl_rq, 10) as sczl_rq,sczl_gdbh,rtrim(g.yj_yjmc) as Gd_cpmc,sczl_yjno,sczl_gxh,sczl_type,
-            sczl_jtbh,sum(班组车头产量) as 班组车头产量,工序难度系数 as 产量系数,(sum(班组车头产量*工序难度系数)) as 计件产量,
-            sum(班组换算产量) as 补产产量,(sum(班组车头产量*工序难度系数)+sum(班组换算产量)) as 核算产量,日定额,sum(达标定额)
-            as 达标定额,千件工价,补产标准,sum(个人计件工资) as 个人计件工资,sum(个人加班工资) as 个人加班工资,Rate as 个人比例,
-            sum(装版工时) as 装版工时,sum(保养工时) as 保养工时,sum(打样工时) as 打样工时,sum(计时补差额工资) as 计时补差')
-            ->join('工单_印件资料 g','g.Yj_Gdbh = 绩效工资汇总.sczl_gdbh AND g.yj_Yjno = 绩效工资汇总.sczl_yjno','LEFT')
-            ->group('LEFT(sczl_rq, 10),sczl_gdbh')
-            ->where(['sczl_rq'=>['between',"$start_time,$end_time"],'bh'=>$req['code']])
-            ->select();
-        if(!$res){
-            $this->error('失败');
-        }
-        foreach($res as &$v){
-            $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']);
-            if($v['sczl_yjno']>9){
-                $sczl_yjno=$v['sczl_yjno'];
-            }else{
-                $sczl_yjno='0'.$v['sczl_yjno'];
-            }
-            unset($v['sczl_yjno']);
-            if($v['sczl_gxh']>9){
-                $sczl_gxh=$v['sczl_gxh'];
-            }else{
-                $sczl_gxh='0'.$v['sczl_gxh'];
-            }
-            unset($v['sczl_gxh']);
-            $v['sczl_type']=$sczl_yjno.'-'.$sczl_gxh.'-->'.$v['sczl_type'];
-        }
-        $this->success('成功',$res);
-    }
-    /**
-     * 定位
-     * @ApiMethod GET
-    */
-    public function search(){
-      
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $yg = db()->table('人事_基本资料')->where('员工姓名',$req['search'])->value('员工编号');
-        // $yg = db()->table('人事_基本资料')->where('员工姓名','like','%'.$req['search'].'%')->column('员工编号');
-
-        if($yg){
-            $req['search']=$yg;
-        }
-        $res=db('绩效工资汇总')->alias('j')
-            ->join('人事_基本资料 r','r.员工编号=j.bh')
-            ->group('j.bh')
-            ->where('j.sys_ny',$req['date'])
-            ->where('j.bh',$req['search'])
-            // ->where(['r.所在部门'=>['like',$req['department'].'%']])
-            ->column('CONCAT(j.bh, "-", DATE_FORMAT(sczl_rq,"%Y.%m")) AS rq_bh,j.bh,rtrim(j.xm) as 员工姓名,r.工资表类别,DATE_FORMAT(r.聘用日期,"%Y.%m.%d") as 聘用日期,j.法定天数,
-            sum(j.达标定额) as 当月定额,(sum(j.班组车头产量*j.工序难度系数)+sum(j.班组换算产量)) as 月度合计产量,sum(j.个人计件工资) as 个人计件工资,
-            sum(j.个人加班工资) as 个人加班工资,sum(j.异常停机工时) as 月计时时数,LEFT(j.sczl_rq, 7) as sczl_rq');
-
-        $year=substr($req['date'],0,4);
-        $month=substr($req['date'],-2);
-        $start_time = $year . '-' . $month . '-01 00:00:00';
-        $end_time = date('Y-m-t', strtotime("$year-$month-01")) . ' 23:59:59';
-        $arr = [];
-        $columns = ['wgjs_bh1', 'wgjs_bh2', 'wgjs_bh3', 'wgjs_bh4', 'wgjs_bh5', 'wgjs_bh6'];
-        for ($i = 1; $i <= 6; $i++) {
-            $column = $columns[$i-1];
-            $r = db('db_wgjs')
-                ->field("DATE_FORMAT(wgjs_rq,'%Y.%m') as wgjs_rq, $column as wgjs_bh, wgjs_js$i as wgjs_js, wgjs_冲定额$i as wgjs_冲定额")
-                ->join('人事_基本资料', "人事_基本资料.员工编号=db_wgjs.$column")
-                ->where($column,$req['search'])
-                ->where(['wgjs_rq' => ['between', "$start_time,$end_time"]])
-                ->select();
-
-            $arr = array_merge($arr, $r);
-        }
-
-        $list = [];
-        foreach($arr as $v){
-            if(isset($list[$v['wgjs_bh'].'-'.$v['wgjs_rq']])){
-                if($v['wgjs_冲定额']=='是'){
-                    $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']+=$v['wgjs_js'];
-                }
-            }else{
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['bh']=$v['wgjs_bh'];
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['sczl_rq']=$v['wgjs_rq'];
-                if($v['wgjs_冲定额']=='是'){
-                    $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=$v['wgjs_js'];
-                }else{
-                    $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=0;
-                }
-            }
-        };
-
-        //获取每个员工计时补差天数
-        $arr1 = db('绩效工资汇总')->alias('j')
-            ->field('j.bh,j.sczl_rq')
-            ->join('人事_基本资料 r','r.员工编号=j.bh')
-            ->group('j.bh,j.sczl_rq')
-            ->where('j.sys_ny',$req['date'])
-            ->where('j.bh',$req['search'])
-            // ->where('j.达标定额','<>',0)
-            // ->where(['r.所在部门'=>['like',$req['department'].'%']])
-            ->buildSql();
-        $arr1 = db()->table($arr1 . ' t')
-            ->group('t.bh, LEFT(t.sczl_rq, 7)')
-            ->column('t.bh,count(LEFT(t.sczl_rq, 7)) as num');
-
-        //查询每条记录
-        $arr2 = db('绩效工资汇总')->alias('j')
-            ->field('j.bh, DATE_FORMAT(j.sczl_rq,"%Y.%m") as sczl_rq,
-            sum(j.达标定额) as 达标定额, j.Rate, j.千件工价')
-            ->join('人事_基本资料 r','r.员工编号=j.bh')
-            ->where('j.sys_ny',$req['date'])
-            // ->where('j.达标定额','<>',0)
-            ->where('j.bh',$req['search'])
-            // ->where(['r.所在部门'=>['like',$req['department'].'%']])
-            ->group('j.bh,j.sczl_rq,j.sczl_gdbh')
-            ->select();
-        //计算每条记录的计时补差
-        $brr = [];
-        foreach($arr2 as $v){
-            $yjsss1 = array_key_exists($v['bh'].'-'.$v['sczl_rq'],$list) ? $list[$v['bh'].'-'.$v['sczl_rq']]['月计时时数'] : 0;
-            $yjsss2 = array_key_exists($v['bh'].'-'.$v['sczl_rq'],$res) ? $res[$v['bh'].'-'.$v['sczl_rq']]['月计时时数'] : 0;
-            $yjsss = $yjsss1 + $yjsss2;
-            $a = $yjsss/$arr1[$v['bh']]/11*0.6*$v['达标定额']*$v['Rate']*0.5/1000*$v['千件工价'];
-                
-            if(array_key_exists($v['bh'].'-'.$v['sczl_rq'],$brr)){
-                $brr[$v['bh'].'-'.$v['sczl_rq']] += $a;
-            }else{
-                $brr[$v['bh'].'-'.$v['sczl_rq']] = $a;
-            }
-        }
-
-        foreach($res as $k=>&$v){
-            if(array_key_exists($k,$list)){
-                $v['月计时时数'] += $list[$k]['月计时时数'];
-            }
-            $v['工资表类别'] = trim($v['工资表类别']);
-            $v['法定天数'] = round($v['法定天数']);
-            $v['当月定额'] = round($v['当月定额']);
-            $v['月度合计产量'] = round($v['月度合计产量']);
-            $v['月计时时数'] = floatval(number_format($v['月计时时数'],2, '.', ''));
-            $v['计时补差'] = floatval(number_format($brr[$k],2, '.', ''));
-            unset($v['rq_bh']);
-        }
-        $res = array_values($res);
-        $this->success('成功',$res);
-        $arr = [];
-        $columns = ['wgjs_bh1', 'wgjs_bh2', 'wgjs_bh3', 'wgjs_bh4', 'wgjs_bh5', 'wgjs_bh6'];
-        $field = 'wgjs_js';
-        for ($i = 1; $i <= 6; $i++) {
-            $column = $columns[$i-1];
-            $r = db('db_wgjs')
-                ->field("DATE_FORMAT(wgjs_rq,'%Y.%m') as wgjs_rq, $column as wgjs_bh, ${field}${i} as wgjs_js")
-                ->join('人事_基本资料', "人事_基本资料.员工编号=db_wgjs.$column")
-                ->where(['wgjs_rq' => ['between', "$start_time,$end_time"]])
-                ->select();
-
-            $arr = array_merge($arr, $r);
-        }
-
-        $list = [];
-        foreach($arr as $v){
-            if(isset($list[$v['wgjs_bh'].'-'.$v['wgjs_rq']])){
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']+=$v['wgjs_js'];
-            }else{
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['bh']=$v['wgjs_bh'];
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['sczl_rq']=$v['wgjs_rq'];
-                $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=$v['wgjs_js'];
-            }
-        };
-        
-        foreach($res as $k=>&$v){
-            if(array_key_exists($k,$list)){
-                $v['月计时时数'] += $list[$k]['月计时时数'];
-            }
-            $v['工资表类别'] = trim($v['工资表类别']);
-            $v['法定天数'] = round($v['法定天数']);
-            $v['当月定额'] = round($v['当月定额']);
-            $v['月度合计产量'] = round($v['月度合计产量']);
-            $v['月计时时数'] = floatval(number_format($v['月计时时数'],2, '.', ''));
-            $v['计时补差'] = floatval(bcmul($v['月计时时数'], 9.5, 2));
-            unset($v['rq_bh']);
-        }
-        $res = array_values($res);
-        $this->success('成功',$res);
-    }
-}

+ 0 - 803
application/api/controller/PackagingCountDocument.php

@@ -1,803 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use Overtrue\Pinyin\Pinyin;
-use PhpOffice\PhpSpreadsheet\Spreadsheet;
-use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-
-/**
- * 包装计件单据维护接口
- */
-class PackagingCountDocument extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取包装计件单据侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        //判断是否存在缓存
-        if (!cache('PackagingCountDocument-getTab')){
-            $rows = db()->table('db_包装计件')
-                ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
-                ->group('date')
-                ->order('UniqId desc')
-                ->limit(30)
-                ->select();
-
-            $arr = db()->table('db_包装计件')
-                ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(*) as count')
-                ->where('sys_rq','>=',$rows[count($rows)-1]['date'])
-                ->group('date, sys_id')
-                ->select();
-            //设置缓存
-            cache('PackagingCountDocument-getTab',['rows'=>$rows,'arr'=>$arr],3600);
-        }else{
-            $rows = cache('PackagingCountDocument-getTab')['rows'];
-            $arr = cache('PackagingCountDocument-getTab')['arr'];
-        }
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['sys'] = [];
-            foreach($arr as $k=>$v){
-                if($value['date'] == $v['date']){
-                    unset($v['date']);
-                    array_push($rows[$key]['sys'],$v);
-                    unset($arr[$k]);
-                }
-            }
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
-        }
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取包装计件单据列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['sys_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE',$req['sys_id'].'%'];
-
-        $rows = db()->table('db_包装计件')
-            ->field('sczl_bh, LEFT(sczl_rq, 10) as sczl_rq, sczl_bzdh, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl, 
-            sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgsl, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl, 
-            sczl_gdbh1, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
-            ->where($where)
-            ->page($page,$limit)
-            ->select();
-        $total = db()->table('db_包装计件')->where($where)->count();
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value) {
-            $rows[$key]['sczl_cl'] = floatval($value['sczl_cl']);
-            $rows[$key]['sczl_fgsl'] = floatval($value['sczl_fgsl']);
-            $rows[$key]['sczl_jjcl'] = floatval($value['sczl_jjcl']);
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['name'] = array_key_exists($value['sczl_bh'],$rs) ? trim($rs[$value['sczl_bh']]) : '';
-        }
-
-        $data = [
-            'total'          => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 定位
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $cpmc 产品名称
-     * @param string $page 页码
-     * @param string $limit 数量
-     */
-    public function locate()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $where = [
-                'sczl_gdbh1|sczl_gdbh2|sczl_gdbh3|sczl_gdbh4|sczl_gdbh5|sczl_gdbh6'=>[ 'like', '%' . $req['gdbh'] . '%']
-            ];
-            $rows = db()->table('db_包装计件')
-                ->field('sczl_bh, LEFT(sczl_rq, 10) as sczl_rq, sczl_bzdh, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl, 
-            sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgsl, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl, 
-            sczl_gdbh1, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
-                ->where($where)
-                ->page($page,$limit)
-                ->select();
-            $total = db()->table('db_包装计件')->where($where)->count();
-        }else{
-            if (isset($req['cpmc']) && !empty($req['cpmc'])){
-                //查询工单表
-                $gd = db()->table('工单_基本资料')
-                    ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
-                    ->column('Gd_gdbh');
-                $where = [
-                    'sczl_gdbh1|sczl_gdbh2|sczl_gdbh3|sczl_gdbh4|sczl_gdbh5|sczl_gdbh6'=>['in', $gd]
-                ];
-                $rows = db()->table('db_包装计件')
-                    ->field('sczl_bh, LEFT(sczl_rq, 10) as sczl_rq, sczl_bzdh, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl, 
-            sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgsl, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl, 
-            sczl_gdbh1, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
-                    ->where($where)
-                    ->page($page,$limit)
-                    ->select();
-                $total = db()->table('db_包装计件')->where($where)->count();
-            }else{
-                $this->error('参数错误');
-            }
-        }
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value){
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['sczl_cl'] = floatval($value['sczl_cl']);
-            $rows[$key]['sczl_fgsl'] = floatval($value['sczl_fgsl']);
-            $rows[$key]['sczl_jjcl'] = floatval($value['sczl_jjcl']);
-            $rows[$key]['name'] = array_key_exists($value['sczl_bh'],$rs) ? trim($rs[$value['sczl_bh']]) : '';
-        }
-        $data = [
-            'total'    => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-        $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
-        $rows = db()->table('db_包装计件')
-            ->field('LEFT(sczl_rq, 10) as sczl_rq, sczl_bh, sczl_bzdh, sczl_jsss, sczl_冲定额, 
-            sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6, 
-            rtrim(sczl_yjGx1) as sczl_yjGx1, rtrim(sczl_yjGx2) as sczl_yjGx2, rtrim(sczl_yjGx3) as sczl_yjGx3, rtrim(sczl_yjGx4) as sczl_yjGx4, rtrim(sczl_yjGx5) as sczl_yjGx5, rtrim(sczl_yjGx6) as sczl_yjGx6, 
-            rtrim(sczl_gxmc1) as sczl_gxmc1, rtrim(sczl_gxmc2) as sczl_gxmc2, rtrim(sczl_gxmc3) as sczl_gxmc3, rtrim(sczl_gxmc4) as sczl_gxmc4, rtrim(sczl_gxmc5) as sczl_gxmc5, rtrim(sczl_gxmc6) as sczl_gxmc6, 
-            sczl_cl1, sczl_cl2, sczl_cl3, sczl_cl4, sczl_cl5, sczl_cl6, 
-            sczl_PgCl1, sczl_PgCl2, sczl_PgCl3, sczl_PgCl4, sczl_PgCl5, sczl_PgCl6,
-            sczl_type1, sczl_type2, sczl_type3, sczl_type4, sczl_type5, sczl_type6, 
-            sczl_返工产量1, sczl_返工产量2, sczl_返工产量3, sczl_返工产量4, sczl_返工产量5, sczl_返工产量6, 
-            sczl_计产系数1, sczl_计产系数2, sczl_计产系数3, sczl_计产系数4, sczl_计产系数5, sczl_计产系数6, 
-            rtrim(sczl_Jtbh1) as sczl_Jtbh1, rtrim(sczl_Jtbh2) as sczl_Jtbh2, rtrim(sczl_Jtbh3) as sczl_Jtbh3, rtrim(sczl_Jtbh4) as sczl_Jtbh4, rtrim(sczl_Jtbh5) as sczl_Jtbh5, rtrim(sczl_Jtbh6) as sczl_Jtbh6, 
-            rtrim(sczl_dedh1) as sczl_dedh1, rtrim(sczl_dedh2) as sczl_dedh2, rtrim(sczl_dedh3) as sczl_dedh3, rtrim(sczl_dedh4) as sczl_dedh4, rtrim(sczl_dedh5) as sczl_dedh5, rtrim(sczl_dedh6) as sczl_dedh6, 
-            rtrim(sczl_desc) as sczl_desc')
-            ->where('UniqId',$UniqId)
-            ->find();
-        $rs = db()->table('人事_基本资料')->field('员工姓名')->where('员工编号',$rows['sczl_bh'])->find();
-        $rows['name'] = $rs ? trim($rs['员工姓名']) : '';
-        for ($i=1;$i<=6;$i++){
-            $rows['Gd_cpmc'.$i] = array_key_exists($rows['sczl_gdbh'.$i], $gd) ? trim($gd[$rows['sczl_gdbh'.$i]]) : '';
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询印件工序及产品名称
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $gxmc 工序名称
-     */
-    public function getGxMc()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-        $gxmc = ['包装','成品防护'];
-
-        $gxmcs = [];
-        foreach ($gxmc as $k=>$v){
-            array_push($gxmcs,['like','%'.$v.'%']);
-        }
-        array_push($gxmcs,'OR');
-
-        $rows = db()->table('工单_印件资料')->alias('g')
-            ->field('rtrim(g.yj_yjmc) as Gd_cpmc, g.yj_Yjno as Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc')
-            ->where(['g.Yj_Gdbh'=>$gdbh])
-            ->where(['c.Gy0_gxmc'=>$gxmcs])
-            ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Yj_Gdbh and g.yj_Yjno=c.Gy0_yjno')
-            ->select();
-
-        foreach ($rows as $key=>$value){
-            $rows[$key]['jyGx'] =  sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取单个汉字的首字母
-     * @param string $chineseChar 单个汉字
-     * @return string|null 首字母(大写)或 null(如果不是有效的汉字)
-     */
-    function getChineseCharInitial($chineseChar) {
-        // 使用正则表达式匹配合法的汉字字符
-        if (!preg_match('/^[\x{4e00}-\x{9fa5}]$/u', $chineseChar)) {
-            return null;
-        }
-        // 将输入的汉字转换为 GBK 编码
-        $gbk = iconv('UTF-8', 'GBK', $chineseChar);
-        // 计算汉字的拼音首字母
-        $initial = '';
-        // 获取首字母的 ASCII 值
-        $asc = ord($gbk[0]) * 256 + ord($gbk[1]);
-        // 汉字范围的对应拼音首字母范围
-        $zhFirstLetterRanges = array(
-            array(45217, 45252,'A'), // A
-            array(45253, 45760,'B'), // B
-            array(45761, 46317,'C'), // C
-            array(46318, 46825,'D'), // D
-            array(46826, 47009,'E'), // E
-            array(47010, 47296,'F'), // F
-            array(47297, 47613,'G'), // G
-            array(47614, 48118,'H'), // H
-            array(48119, 49061,'J'), // J
-            array(49062, 49323,'K'), // K
-            array(49324, 49895,'L'), // L
-            array(49896, 50370,'M'), // M
-            array(50371, 50613,'N'), // N
-            array(50614, 50621,'O'), // O
-            array(50622, 50905,'P'), // P
-            array(50906, 51386,'Q'), // Q
-            array(51387, 51445,'R'), // R
-            array(51446, 52217,'S'), // S
-            array(52218, 52697,'T'), // T
-            array(52698, 52979,'W'), // W
-            array(52980, 53688,'X'), // X
-            array(53689, 54480,'Y'), // Y
-            array(54481, 55289,'Z')  // Z
-        );
-        // 判断汉字的拼音首字母范围并返回对应的字母
-        foreach ($zhFirstLetterRanges as $key => $range) {
-            if ($asc >= $range[0] && $asc <= $range[1]) {
-                $initial = $range[2];
-                break;
-            }
-        }
-    
-        return $initial;
-    }
-
-    /**
-     * 查询员工名称
-     * @ApiMethod (GET)
-     * @param string $sczl_bh 员工编号
-     */
-    public function getYg()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['sczl_bh']) && !empty($req['sczl_bh'])){
-            $sczl_bh = $req['sczl_bh'];
-        }else{
-            $this->error('参数错误');
-        }
-        // $rows = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['在职状态'=>'在职'])->select();
-        // $data = [];
-        // $pinyin = new Pinyin();
-        // foreach ($rows as $v){
-        //     $sx = '';
-        //     for($i=0; $i<mb_strlen($v['ygxm']); $i++){
-        //         $str = mb_substr($v['ygxm'],$i,1);
-        //         $bool = $this->getChineseCharInitial($str);
-        //         if($bool){
-        //             $sx .= $this->getChineseCharInitial($str);
-        //         }else{
-        //             $sx .= strtoupper($pinyin->abbr($str));
-        //         }
-        //     }
-        //     $data[$sx][] = $v;
-        // }
-        // $sx = strtoupper($sczl_bh);
-        // if(array_key_exists($sx,$data)){
-        //     $this->success('成功',$data[$sx]);
-        // }
-
-        $rs = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['pycode'=>$sczl_bh,'在职状态'=>'在职'])->select();
-        if($rs){
-            $this->success('成功',$rs);
-        }
-        $rs = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['员工编号'=>$sczl_bh,'在职状态'=>'在职'])->select();
-        if($rs===false){
-            $this->error('员工编号错误');
-        }
-        $this->success('成功',$rs);
-    }
-
-/**
-     * 查询定额代号
-     * @ApiMethod (GET)
-     */
-    public function getDedh()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-
-        $row = db('dic_lzde')
-            ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
-            ->where('sys_mc','in',['包装','成品防护'])
-            ->select();
-        foreach ($row as $n=>$m){
-            $rows = db('dic_lzde')
-                ->field('Key_, sys_bh, rtrim(sys_mc) as sys_mc')
-                ->where('Parent',$m['Key_'])
-                ->order('sys_bh asc')
-                ->select();
-            foreach ($rows as $key=>$value){
-                $bool = db('dic_lzde')
-                    ->field('Key_,sys_bh, rtrim(sys_mc) as sys_mc')
-                    ->where('Parent',$value['Key_'])
-                    ->order('sys_bh asc')
-                    ->select();
-                if ($bool){
-                    foreach ($bool as $k=>$v){
-                        $bool1 = db('dic_lzde')
-                            ->field('sys_bh, rtrim(sys_mc) as sys_mc')
-                            ->where('Parent',$v['Key_'])
-                            ->order('sys_bh asc')
-                            ->select();
-
-                        if ($bool1){
-                            $bool[$k]['bh_mc'] = $bool1;
-                        }
-                    }
-                    $rows[$key]['bh_mc'] = $bool;
-                }
-            }
-            $row[$n]['bh_mc'] = $rows;
-        }
-        $this->success('成功',$row);
-    }
-    
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string 'sys_id'
-     */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sys_id','sczl_rq', 'sczl_bh', 'sczl_jsss', 'sczl_冲定额', 'sczl_bzdh',
-            'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
-            'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
-            'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
-            'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
-            'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
-            'sczl_返工产量1', 'sczl_返工产量2', 'sczl_返工产量3', 'sczl_返工产量4', 'sczl_返工产量5', 'sczl_返工产量6',
-            'sczl_计产系数1', 'sczl_计产系数2', 'sczl_计产系数3', 'sczl_计产系数4', 'sczl_计产系数5', 'sczl_计产系数6',
-            'sczl_Jtbh1','sczl_Jtbh2', 'sczl_Jtbh3', 'sczl_Jtbh4', 'sczl_Jtbh5', 'sczl_Jtbh6',
-            'sczl_dedh1', 'sczl_dedh2', 'sczl_dedh3', 'sczl_dedh4', 'sczl_dedh5', 'sczl_dedh6',
-            'sczl_desc','sczl_type1','sczl_type2','sczl_type3','sczl_type4','sczl_type5','sczl_type6'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['sys_rq'] = date('Y-m-d H:i:s');
-
-        //查询UniqId
-        $UniqId = db()->table('db_包装计件')->max('UniqId');
-        $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db()->table('db_包装计件')->fetchSql(true)->insert($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-            cache('PackagingCountDocument-getTab',null);
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId',
-     */
-    public function edit()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sys_id','sczl_rq', 'sczl_bh', 'sczl_jsss', 'sczl_冲定额', 'sczl_bzdh',
-            'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
-            'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
-            'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
-            'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
-            'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
-            'sczl_返工产量1', 'sczl_返工产量2', 'sczl_返工产量3', 'sczl_返工产量4', 'sczl_返工产量5', 'sczl_返工产量6',
-            'sczl_计产系数1', 'sczl_计产系数2', 'sczl_计产系数3', 'sczl_计产系数4', 'sczl_计产系数5', 'sczl_计产系数6',
-            'sczl_Jtbh1','sczl_Jtbh2', 'sczl_Jtbh3', 'sczl_Jtbh4', 'sczl_Jtbh5', 'sczl_Jtbh6',
-            'sczl_dedh1', 'sczl_dedh2', 'sczl_dedh3', 'sczl_dedh4', 'sczl_dedh5', 'sczl_dedh6',
-            'sczl_desc','sczl_type1','sczl_type2','sczl_type3','sczl_type4','sczl_type5','sczl_type6'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                continue;
-            }
-            $data[$value] = $req[$value];
-        }
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-        if (count($data)==0){
-            $this->error('参数错误','',111);
-        }
-        $data['mod_rq'] = date('Y-m-d H:i:s');
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db()->table('db_包装计件')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-            cache('PackagingCountDocument-getTab',null);
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId'
-     */
-    public function del()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db()->table('db_包装计件')->where('UniqId',$req['UniqId'])->delete();
-            // 提交事务
-            db()->commit();
-            cache('PackagingCountDocument-getTab',null);
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 导出到excel
-     * @ApiMethod (POST)
-     * @param string gxmc
-     * @param string start_time
-     * @param string end_time
-     * @param string file_name
-     * @param array fields
-     */
-    public function processExport(){
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'gxmc','start_time', 'end_time', 'file_name'
-        ];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-        }
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-        $field = '';
-        $arr = [
-            'sczl_rq'       =>['日期','LEFT(sczl_rq, 10) as sczl_rq'],
-            'sczl_bh'       =>['员工编号','sczl_bh'],
-            'sczl_name'     =>['员工姓名','sczl_bh'],
-            'sczl_jsss'     =>['计时时数','sczl_jsss'],
-            'sczl_gdbh'     =>['工单编号','sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6'],
-            'sczl_yjmc'     =>['印件名称','sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6'],
-            'sczl_yjGx'     =>['印件工序','rtrim(sczl_yjGx1) as sczl_yjGx1, rtrim(sczl_yjGx2) as sczl_yjGx2, rtrim(sczl_yjGx3) as sczl_yjGx3, rtrim(sczl_yjGx4) as sczl_yjGx4, rtrim(sczl_yjGx5) as sczl_yjGx5, rtrim(sczl_yjGx6) as sczl_yjGx6'],
-            'sczl_gxmc'     =>['工序名称','rtrim(sczl_gxmc1) as sczl_gxmc1, rtrim(sczl_gxmc2) as sczl_gxmc2, rtrim(sczl_gxmc3) as sczl_gxmc3, rtrim(sczl_gxmc4) as sczl_gxmc4, rtrim(sczl_gxmc5) as sczl_gxmc5, rtrim(sczl_gxmc6) as sczl_gxmc6'],
-            'sczl_cl'       =>['产量','sczl_cl1, sczl_cl2, sczl_cl3, sczl_cl4, sczl_cl5, sczl_cl6'],
-            'sczl_PgCl'     =>['每箱产量','sczl_PgCl1, sczl_PgCl2, sczl_PgCl3, sczl_PgCl4, sczl_PgCl5, sczl_PgCl6'],
-            'sczl_计产系数'  =>['计产系数','sczl_计产系数1, sczl_计产系数2, sczl_计产系数3, sczl_计产系数4, sczl_计产系数5, sczl_计产系数6'],
-            'sczl_dedh'     =>['定额代号','rtrim(sczl_dedh1) as sczl_dedh1, rtrim(sczl_dedh2) as sczl_dedh2, rtrim(sczl_dedh3) as sczl_dedh3, rtrim(sczl_dedh4) as sczl_dedh4, rtrim(sczl_dedh5) as sczl_dedh5, rtrim(sczl_dedh6) as sczl_dedh6']
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                if ($k==0){
-                    $field .= $arr[$v][1];
-                }else{
-                    $field .= ','.$arr[$v][1];
-                }
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        //根据条件查询数据
-        $rows = db()->table('db_包装计件')
-            ->field($field)
-            ->where('sczl_rq','between',[$req['start_time'],$req['end_time']])
-            ->where(['sczl_gxmc1|sczl_gxmc2|sczl_gxmc3|sczl_gxmc4|sczl_gxmc5|sczl_gxmc6'=>['like','%'.$req['gxmc'].'%']])
-            ->select();
-        $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-
-        for ($i = 1; $i <= 6; $i++) {
-            foreach ($rows as $key=>$value){
-                if (trim($value['sczl_gdbh'.$i])=='') continue;
-                if (trim($value['sczl_gxmc'.$i])!=$req['gxmc']) continue;
-                $subArray = [];
-                foreach ($req['fields'] as $k=>$v){
-                    if(array_key_exists($v,$arr)){
-                        if($v=='sczl_rq' || $v=='sczl_jsss' || $v=='sczl_bh'){
-                            if($value[$v]){
-                                array_push($subArray,$value[$v]);
-                            }else{
-                                array_push($subArray,'');
-                            }
-                        }else if($v=='sczl_name'){
-                            $name = array_key_exists($value['sczl_bh'],$rs) ? trim($rs[$value['sczl_bh']]) : '';
-                            if($name){
-                                array_push($subArray,$name);
-                            }else{
-                                array_push($subArray,'');
-                            }
-                        }else if($v=='sczl_yjmc'){
-                            $cpmc = array_key_exists($value['sczl_gdbh'.$i],$gd) ? trim($gd[$value['sczl_gdbh'.$i]]) : '';
-                            if($cpmc){
-                                array_push($subArray,$cpmc);
-                            }else{
-                                array_push($subArray,'');
-                            }
-                        }else{
-                            if($value[$v.$i]){
-                                array_push($subArray,$value[$v.$i]);
-                            }else{
-                                array_push($subArray,'');
-                            }
-                        }
-                    }
-                }
-                array_push($data,$subArray);
-            }
-        }
-        $this->Ex($req['file_name'],$data);
-
-//        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-    /**
-     * 工序汇总导出
-     * @ApiMethod (POST)
-     * @param string date
-     * @param string sys_id
-     * @param array fields
-     */
-    public function export(){
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['sys_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE',$req['sys_id'].'%'];
-        if (!(isset($req['fields']) && count($req['fields'])!=0)){
-            $this->error('参数错误','fields',100);
-        }
-
-        $field = '';
-        $arr = [
-            'sczl_bh'       =>['员工编号','sczl_bh'],
-            'sczl_name'     =>['员工姓名','sczl_bh'],
-            'sczl_rq'       =>['生产日期','LEFT(sczl_rq, 10) as sczl_rq'],
-            'sczl_bzdh'     =>['班组','sczl_bzdh'],
-            'sczl_cl'       =>['包装产量','sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl'],
-            'sczl_fgcl'     =>['返工产量','sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgcl'],
-            'sczl_jjcl'     =>['计件产量','sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl'],
-            'sczl_gdbh1'     =>['相关工单','sczl_gdbh1'],
-        ];
-        $data[0] = [];
-        foreach ($req['fields'] as $k=>$v){
-            if(array_key_exists($v,$arr)){
-                if ($k==0){
-                    $field .= $arr[$v][1];
-                }else{
-                    $field .= ','.$arr[$v][1];
-                }
-                array_push($data[0],$arr[$v][0]);
-            }
-        }
-
-        $rows = db()->table('db_包装计件')
-            ->field($field)
-            ->where($where)
-            ->select();
-
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
-        foreach ($rows as $key=>$value) {
-            if (isset($value['sczl_cl'])) $value['sczl_cl'] = floatval($value['sczl_cl']);
-            if (isset($value['sczl_fgcl'])) $value['sczl_fgcl'] = floatval($value['sczl_fgcl']);
-            if (isset($value['sczl_jjcl'])) $value['sczl_jjcl'] = floatval($value['sczl_jjcl']);
-            $subArray = [];
-            foreach ($req['fields'] as $k=>$v){
-                if(array_key_exists($v,$arr)){
-                    if($v=='sczl_name'){
-                        $name = array_key_exists($value['sczl_bh'],$rs) ? trim($rs[$value['sczl_bh']]) : '';
-                        if($name){
-                            array_push($subArray,$name);
-                        }else{
-                            array_push($subArray,'');
-                        }
-                    }else{
-                        if($value[$v]){
-                            array_push($subArray,$value[$v]);
-                        }else{
-                            array_push($subArray,'');
-                        }
-                    }
-                }
-            }
-            array_push($data,$subArray);
-        }
-        $this->Ex($req['file_name'],$data);
-//        $this->success('成功',['file_name'=>$req['file_name'],'data'=>$data]);
-    }
-
-    public function Ex($file_name,$data)
-    {
-        $spreadsheet = new Spreadsheet();
-
-        $sheet = $spreadsheet->getActiveSheet();
-
-        $sheet->setTitle($file_name);
-
-        // 将数据逐行写入工作表
-        foreach ($data as $rowIndex => $rowData) {
-            // 将每个单元格的值写入对应的列
-            foreach ($rowData as $columnIndex => $cellData) {
-                $sheet->setCellValueByColumnAndRow($columnIndex + 1, $rowIndex + 1, $cellData);
-            }
-        }
-        $writer = new Xlsx($spreadsheet);
-        $folderPath = 'uploads/folder';
-
-        if (!is_dir($folderPath)) {
-            mkdir($folderPath, 0777, true);
-            $tempPath = $folderPath .'/'. $file_name.'.xlsx';
-        } else {
-            $tempPath = $folderPath .'/'. $file_name.'.xlsx';
-        }
-
-//        header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
-//        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
-//        $writer->save("php://output"); //表示在$path路径下面生成demo.xlsx文件
-        $writer->save($tempPath);
-
-        // 获取完整url
-        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
-        $host = $_SERVER['HTTP_HOST'];
-        $siteUrl = $protocol . '://' . $host .'/'.$tempPath ;
-
-        $this->success('成功', $siteUrl);
-    }
-
-}

+ 0 - 399
application/api/controller/PackagingProcessOutput.php

@@ -1,399 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-
-/**
- * 包装工序产量维护接口
- */
-class PackagingProcessOutput extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $rows = db()->table('db_包装产量预报')
-            ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
-            ->group('date')
-            ->order('UniqId desc')
-            ->limit(30)
-            ->select();
-
-        $arr = db()->table('db_包装产量预报')
-            ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(*) as count')
-            ->where('sys_rq','>=',$rows[count($rows)-1]['date'])
-            ->group('date, sys_id')
-            ->select();
-
-        foreach($rows as $key=>$value){
-            $rows[$key]['sys'] = [];
-            foreach($arr as $k=>$v){
-                if($value['date'] == $v['date']){
-                    unset($v['date']);
-                    array_push($rows[$key]['sys'],$v);
-                    unset($arr[$k]);
-                }
-            }
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $sys_id 用户
-     * @param string $page 页码
-     * @param string $limit 数量
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['sys_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
-        }
-        if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE',$req['sys_id'].'%'];
-
-        $rows = db()->table('db_包装产量预报')
-            ->field('rtrim(sys_id) as sys_id, LEFT(sczl_rq, 10) as sczl_rq, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl, 
-            (sczl_cl1 * sczl_PgCl1 + sczl_clAdd1) + (sczl_cl2 * sczl_PgCl2 + sczl_clAdd2) + (sczl_cl3 * sczl_PgCl3 + sczl_clAdd3) + (sczl_cl4 * sczl_PgCl4 + sczl_clAdd4) + (sczl_cl5 * sczl_PgCl5 + sczl_clAdd5) + (sczl_cl6 * sczl_PgCl6 + sczl_clAdd6) as sczl_PgCl, 
-            sys_rq, mod_rq, UniqId')
-            ->where($where)
-            ->page($page,$limit)
-            ->select();
-        $total = db()->table('db_包装产量预报')->where($where)->count();
-
-        $sczl_cls = $sczl_PgCls = 0;
-        foreach ($rows as $key=>$value){
-            $sczl_cls += $value['sczl_cl'];
-            $sczl_PgCls += $value['sczl_PgCl'];
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['sczl_cl'] = floatval($value['sczl_cl']);
-            $rows[$key]['sczl_PgCl'] = floatval($value['sczl_PgCl']);
-        }
-        $data = [
-            'sczl_cls'      => $sczl_cls,
-            'sczl_PgCls'    => $sczl_PgCls,
-            'total'    => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 定位
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $cpmc 产品名称
-     * @param string $page 页码
-     * @param string $limit 数量
-     */
-    public function locate()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $where = [
-                'sczl_gdbh1|sczl_gdbh2|sczl_gdbh3|sczl_gdbh4|sczl_gdbh5|sczl_gdbh6'=>[ 'like', '%' . $req['gdbh'] . '%']
-            ];
-            $rows = db()->table('db_包装产量预报')
-                ->field('rtrim(sys_id) as sys_id, LEFT(sczl_rq, 10) as sczl_rq, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl, 
-            (sczl_cl1 * sczl_PgCl1 + sczl_clAdd1) + (sczl_cl2 * sczl_PgCl2 + sczl_clAdd2) + (sczl_cl3 * sczl_PgCl3 + sczl_clAdd3) + (sczl_cl4 * sczl_PgCl4 + sczl_clAdd4) + (sczl_cl5 * sczl_PgCl5 + sczl_clAdd5) + (sczl_cl6 * sczl_PgCl6 + sczl_clAdd6) as sczl_PgCl, 
-            sys_rq, mod_rq, UniqId')
-                ->where($where)
-                ->page($page,$limit)
-                ->select();
-            $total = db()->table('db_包装产量预报')->where($where)->count();
-        }else{
-            if (isset($req['cpmc']) && !empty($req['cpmc'])){
-                //查询工单表
-                $gd = db()->table('工单_基本资料')
-                    ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
-                    ->column('Gd_gdbh');
-                $where = [
-                    'sczl_gdbh1|sczl_gdbh2|sczl_gdbh3|sczl_gdbh4|sczl_gdbh5|sczl_gdbh6'=>['in', $gd]
-                ];
-                $rows = db()->table('db_包装产量预报')
-                    ->field('rtrim(sys_id) as sys_id, LEFT(sczl_rq, 10) as sczl_rq, 
-            sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl, 
-            (sczl_cl1 * sczl_PgCl1 + sczl_clAdd1) + (sczl_cl2 * sczl_PgCl2 + sczl_clAdd2) + (sczl_cl3 * sczl_PgCl3 + sczl_clAdd3) + (sczl_cl4 * sczl_PgCl4 + sczl_clAdd4) + (sczl_cl5 * sczl_PgCl5 + sczl_clAdd5) + (sczl_cl6 * sczl_PgCl6 + sczl_clAdd6) as sczl_PgCl, 
-            sys_rq, mod_rq, UniqId')
-                    ->where($where)
-                    ->page($page,$limit)
-                    ->select();
-                $total = db()->table('db_包装产量预报')->where($where)->count();
-            }else{
-                $this->error('参数错误');
-            }
-        }
-
-        foreach ($rows as $key=>$value){
-            $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
-            $rows[$key]['sczl_cl'] = floatval($value['sczl_cl']);
-            $rows[$key]['sczl_PgCl'] = floatval($value['sczl_PgCl']);
-        }
-        $data = [
-            'total'    => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-        $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
-        $rows = db()->table('db_包装产量预报')
-            ->field('LEFT(sczl_rq, 10) as sczl_rq, sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6, 
-            rtrim(sczl_yjGx1) as sczl_yjGx1, rtrim(sczl_yjGx2) as sczl_yjGx2, rtrim(sczl_yjGx3) as sczl_yjGx3, rtrim(sczl_yjGx4) as sczl_yjGx4, rtrim(sczl_yjGx5) as sczl_yjGx5, rtrim(sczl_yjGx6) as sczl_yjGx6, 
-            rtrim(sczl_gxmc1) as sczl_gxmc1, rtrim(sczl_gxmc2) as sczl_gxmc2, rtrim(sczl_gxmc3) as sczl_gxmc3, rtrim(sczl_gxmc4) as sczl_gxmc4, rtrim(sczl_gxmc5) as sczl_gxmc5, rtrim(sczl_gxmc6) as sczl_gxmc6, 
-            sczl_cl1, sczl_cl2, sczl_cl3, sczl_cl4, sczl_cl5, sczl_cl6, 
-            sczl_PgCl1, sczl_PgCl2, sczl_PgCl3, sczl_PgCl4, sczl_PgCl5, sczl_PgCl6, 
-            sczl_clAdd1, sczl_clAdd2, sczl_clAdd3, sczl_clAdd4, sczl_clAdd5, sczl_clAdd6')
-            ->where('UniqId',$UniqId)
-            ->find();
-
-        for ($i=1;$i<=6;$i++){
-            $rows['Gd_cpmc'.$i] = array_key_exists($rows['sczl_gdbh'.$i], $gd) ? trim($gd[$rows['sczl_gdbh'.$i]]) : '';
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 查询印件工序及产品名称
-     * @ApiMethod (GET)
-     * @param string $gdbh 工单编号
-     * @param string $gxmc 工序名称
-     */
-    public function getGxMc()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['gdbh']) && !empty($req['gdbh'])){
-            $gdbh = $req['gdbh'];
-        }else{
-            $this->error('参数错误');
-        }
-        $gxmc = ['包装'];
-
-        $gxmcs = [];
-        foreach ($gxmc as $k=>$v){
-            array_push($gxmcs,['like','%'.$v.'%']);
-        }
-        array_push($gxmcs,'OR');
-
-        $rows = db()->table('工单_印件资料')->alias('g')
-            ->field('rtrim(g.yj_yjmc) as Gd_cpmc, g.yj_Yjno as Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc')
-            ->where(['g.Yj_Gdbh'=>$gdbh])
-            ->where(['c.Gy0_gxmc'=>$gxmcs])
-            ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Yj_Gdbh and g.yj_Yjno=c.Gy0_yjno')
-            ->select();
-        foreach ($rows as $key=>$value){
-            $rows[$key]['jyGx'] =  sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
-        }
-
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 新增
-     * @ApiMethod (POST)
-     * @param string 'sys_id','sczl_rq',
-    */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sys_id','sczl_rq',
-            'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
-            'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
-            'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
-            'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
-            'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
-            'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        $data['sys_rq'] = date('Y-m-d H:i:s');
-
-        //查询UniqId
-        $UniqId = db()->table('db_包装产量预报')->max('UniqId');
-        $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db()->table('db_包装产量预报')->fetchSql(true)->insert($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId',
-     */
-    public function edit()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        $arr = [
-            'sczl_rq',
-            'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
-            'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
-            'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
-            'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
-            'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
-            'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                $this->error('参数错误',$value,$key+1);
-            }
-            $data[$value] = $req[$value];
-        }
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-        $data['mod_rq'] = date('Y-m-d H:i:s');
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db()->table('db_包装产量预报')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-
-    /**
-     * 修改
-     * @ApiMethod (POST)
-     * @param string 'UniqId'
-     */
-    public function del()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db()->table('db_包装产量预报')->where('UniqId',$req['UniqId'])->delete();
-
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-
-    }
-}
-
-

+ 0 - 24
application/api/controller/PieceWork.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use \think\Request;
-use \think\Db;
-/**
- * 计件定额管理接口
- */
-class PieceWork extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-}

+ 0 - 381
application/api/controller/PieceWorkSchedule.php

@@ -1,381 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use \think\Request;
-use \think\Db;
-/**
- * 计件工计时单维护接口
- */
-class PieceWorkSchedule extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-    /**
-     * 获取计件工计时单侧边栏
-     * @ApiMethod (GET)
-     */
-    public function getTab()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $rows = db()->table('db_wgjs')
-            ->field('LEFT(wgjs_rq, 7) as date')
-            ->group('date')
-            ->order('UniqId desc')
-            ->limit(15)
-            ->select();
-        foreach($rows as $key=>$value){
-            $rows[$key]['date'] = str_replace('-', '', $rows[$key]['date']);
-        }
-        $this->success('成功',$rows);
-    }
-
-    /**
-     * 获取计件工计时单列表
-     * @ApiMethod (GET)
-     * @param string $date 时间
-     * @param string $Sczl_bh1 员工编号
-     */
-    public function getList()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        $page = 1;
-        $limit = 15;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-
-        $where = [];
-        if (isset($req['date']) && !empty($req['date'])){
-            $where['wgjs_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db()->table('db_wgjs')
-            ->field('LEFT(wgjs_rq, 10) as wgjs_rq, UniqId, 
-            wgjs_bh1, CAST(wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(wgjs_yy1) as wgjs_yy1, 
-            wgjs_bh2, CAST(wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(wgjs_yy2) as wgjs_yy2, 
-            wgjs_bh3, CAST(wgjs_js3 AS SIGNED) as wgjs_js3, rtrim(wgjs_yy3) as wgjs_yy3, 
-            wgjs_bh4, CAST(wgjs_js4 AS SIGNED) as wgjs_js4, rtrim(wgjs_yy4) as wgjs_yy4, 
-            wgjs_bh5, CAST(wgjs_js5 AS SIGNED) as wgjs_js5, rtrim(wgjs_yy5) as wgjs_yy5, 
-            wgjs_bh6, CAST(wgjs_js6 AS SIGNED) as wgjs_js6, rtrim(wgjs_yy6) as wgjs_yy6')
-            ->where($where)
-            ->order('wgjs_rq desc, UniqId asc')
-            ->page($page,$limit)
-            ->select();
-        $total = db()->table('db_wgjs')->where($where)->count();
-
-        $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名, 所在部门');
-
-        foreach ($rows as $key=>$value){
-            $rows[$key]['wgjs_js1'] = $value['wgjs_js1'] == 0 ? '' : $value['wgjs_js1'];
-            //存在该员工编号
-            if (array_key_exists($value['wgjs_bh1'],$rs)){
-                $rows[$key]['department'] = trim($rs[$value['wgjs_bh1']]['所在部门']);
-                $rows[$key]['name1'] = trim($rs[$value['wgjs_bh1']]['员工姓名']);
-                for ($i=2;$i<=6;$i++){
-                    $rows[$key]['wgjs_js'.$i] = $value['wgjs_js'.$i] == '0.0' ? '' : $value['wgjs_js'.$i];
-                    if ($value['wgjs_bh'.$i]){
-                        if ($value['wgjs_bh'.$i]==$value['wgjs_bh1']){
-                            $rows[$key]['name'.$i] = $rows[$key]['name1'];
-                        }else{
-                            $rows[$key]['name'.$i] = trim($rs[$value['wgjs_bh'.$i]]['员工姓名']);
-                        }
-                    }else{
-                        $rows[$key]['name'.$i] = '';
-                    }
-                }
-            }else{
-                $rows[$key]['department'] = '';
-                $rows[$key]['name1'] = '';
-                for ($i=2;$i<=6;$i++){
-                    $rows[$key]['wgjs_js'.$i] = $value['wgjs_js'.$i] == '0.0' ? '' : $value['wgjs_js'.$i];
-                    $rows[$key]['name'.$i] = '';
-                }
-            }
-        }
-
-        $data = [
-            'total'          => $total,
-            'rows'          => $rows,
-        ];
-        $this->success('成功',$data);
-    }
-
-    /**
-     * 获取计件工计时单信息
-     * @ApiMethod (GET)
-     * @param string $UniqId UniqId
-     */
-    public function getInfo()
-    {
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-        if (isset($req['UniqId']) && !empty($req['UniqId'])){
-            $UniqId = $req['UniqId'];
-        }else{
-            $this->error('参数错误');
-        }
-
-        $rows = db()->table('db_wgjs')->alias('d')
-            ->field('d.*, ')
-            ->join('工单_基本资料 g', 'd.')
-            ->where('d.UniqId',$UniqId)
-            ->select();
-
-
-        $this->success('成功',$rows);
-    }
-    /**
-     * 定位
-     * @ApiMethod GET
-    */
-    public function search(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $req = Request::instance()->param();
-        if (!isset($req['search']) || !isset($req['date'])){
-            $this->error('参数错误');
-        }
-        $page = 1;
-        $limit = 10;
-        if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
-        if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
-        $year=substr($req['date'],0,4);
-        $month=substr($req['date'],-2);
-        $start_time = $year . '-' . $month . '-01 00:00:00';
-        $end_time = date('Y-m-t', strtotime("$year-$month-01")) . ' 23:59:59';
-        $yg = db()->table('人事_基本资料')->where('员工姓名',$req['search'])->value('员工编号');
-        if($yg){
-            $req['search']=$yg;
-        }
-        $where = [
-            'db_wgjs.wgjs_rq'=>['between',"$start_time,$end_time"],
-            'db_wgjs.wgjs_bh1|db_wgjs.wgjs_bh2|db_wgjs.wgjs_bh3|db_wgjs.wgjs_bh4|db_wgjs.wgjs_bh5|db_wgjs.wgjs_bh6'=>['like', '%'.$req['search'].'%']
-        ];
-        $rows = db()->table('db_wgjs')
-        ->field('LEFT(db_wgjs.wgjs_rq, 10) as wgjs_rq, 
-        db_wgjs.wgjs_bh1,trim(rs1.所在部门) as 所在部门, CAST(db_wgjs.wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(db_wgjs.wgjs_yy1) as wgjs_yy1, 
-        db_wgjs.wgjs_bh2, CAST(db_wgjs.wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(db_wgjs.wgjs_yy2) as wgjs_yy2, 
-        db_wgjs.wgjs_bh3, CAST(db_wgjs.wgjs_js3 AS SIGNED) as wgjs_js3, rtrim(db_wgjs.wgjs_yy3) as wgjs_yy3, 
-        db_wgjs.wgjs_bh4, CAST(db_wgjs.wgjs_js4 AS SIGNED) as wgjs_js4, rtrim(db_wgjs.wgjs_yy4) as wgjs_yy4, 
-        db_wgjs.wgjs_bh5, CAST(db_wgjs.wgjs_js5 AS SIGNED) as wgjs_js5, rtrim(db_wgjs.wgjs_yy5) as wgjs_yy5, 
-        db_wgjs.wgjs_bh6, CAST(db_wgjs.wgjs_js6 AS SIGNED) as wgjs_js6, rtrim(db_wgjs.wgjs_yy6) as wgjs_yy6,
-        rtrim(rs1.员工姓名) as name1,rtrim(rs2.员工姓名) as name2,rtrim(rs3.员工姓名) as name3,
-        rtrim(rs4.员工姓名) as name4,rtrim(rs5.员工姓名) as name5,rtrim(rs6.员工姓名) as name6,
-        db_wgjs.UniqId')
-        ->join('人事_基本资料 rs1','rs1.员工编号=db_wgjs.wgjs_bh1','LEFT')
-        ->join('人事_基本资料 rs2','rs2.员工编号=db_wgjs.wgjs_bh2','LEFT')
-        ->join('人事_基本资料 rs3','rs3.员工编号=db_wgjs.wgjs_bh3','LEFT')
-        ->join('人事_基本资料 rs4','rs4.员工编号=db_wgjs.wgjs_bh4','LEFT')
-        ->join('人事_基本资料 rs5','rs5.员工编号=db_wgjs.wgjs_bh5','LEFT')
-        ->join('人事_基本资料 rs6','rs6.员工编号=db_wgjs.wgjs_bh6','LEFT')
-        ->where($where)
-        ->order('wgjs_rq desc, UniqId asc')
-        ->page($page,$limit)
-        ->select();
-        $total = db()->table('db_wgjs')->where($where)->count();
-        $data = ['total'=> $total,'rows'=> $rows];
-        if($rows){
-            $this->success('成功',$data);
-         }else{
-            $this->error('失败');
-         }
-    }
-    /**
-     * 详情
-     * @ApiMethod (GET)
-     * @param string $wgjs_rq 日期
-     * @param string $wgjs_bh1 员工编号
-    */
-    public function detail(){
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        $rows = db('db_wgjs')
-            ->field('LEFT(wgjs_rq, 10) as wgjs_rq, db_wgjs.UniqId, 
-            wgjs_bh1, CAST(wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(wgjs_yy1) as wgjs_yy1, 
-            wgjs_bh2, CAST(wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(wgjs_yy2) as wgjs_yy2, 
-            wgjs_bh3, CAST(wgjs_js3 AS SIGNED) as wgjs_js3, rtrim(wgjs_yy3) as wgjs_yy3, 
-            wgjs_bh4, CAST(wgjs_js4 AS SIGNED) as wgjs_js4, rtrim(wgjs_yy4) as wgjs_yy4, 
-            wgjs_bh5, CAST(wgjs_js5 AS SIGNED) as wgjs_js5, rtrim(wgjs_yy5) as wgjs_yy5, 
-            wgjs_bh6, CAST(wgjs_js6 AS SIGNED) as wgjs_js6, rtrim(wgjs_yy6) as wgjs_yy6,
-            rtrim(rs1.员工姓名) as name1,rtrim(rs2.员工姓名) as name2,rtrim(rs3.员工姓名)
-            as name3,rtrim(rs4.员工姓名) as name4,rtrim(rs5.员工姓名) as name5,rtrim(rs6.员工姓名)
-            as name6,wgjs_冲定额1,wgjs_冲定额2,wgjs_冲定额3,wgjs_冲定额4,wgjs_冲定额5,wgjs_冲定额6')
-            ->join('人事_基本资料 rs1','rs1.员工编号=db_wgjs.wgjs_bh1','LEFT')
-            ->join('人事_基本资料 rs2','rs2.员工编号=db_wgjs.wgjs_bh2','LEFT')
-            ->join('人事_基本资料 rs3','rs3.员工编号=db_wgjs.wgjs_bh3','LEFT')
-            ->join('人事_基本资料 rs4','rs4.员工编号=db_wgjs.wgjs_bh4','LEFT')
-            ->join('人事_基本资料 rs5','rs5.员工编号=db_wgjs.wgjs_bh5','LEFT')
-            ->join('人事_基本资料 rs6','rs6.员工编号=db_wgjs.wgjs_bh6','LEFT')
-            ->where('db_wgjs.UniqId', $req['UniqId'])
-            ->find();
-        if($rows!==false){
-            $this->success('成功',$rows);
-        }else{
-            $this->error('失败');
-        }   
-    }
-     /**
-     * 修改
-     * @ApiMethod POST
-    */
-    public function edit()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        $arr = [
-            'wgjs_rq', 
-            'wgjs_bh1', 'wgjs_bh2', 'wgjs_bh3', 'wgjs_bh4', 'wgjs_bh5', 'wgjs_bh6', 
-            'wgjs_js1', 'wgjs_js2', 'wgjs_js3', 'wgjs_js4', 'wgjs_js5', 'wgjs_js6', 
-            'wgjs_yy1', 'wgjs_yy2', 'wgjs_yy3', 'wgjs_yy4', 'wgjs_yy5', 'wgjs_yy6', 
-            'wgjs_冲定额1', 'wgjs_冲定额2', 'wgjs_冲定额3', 'wgjs_冲定额4', 'wgjs_冲定额5', 'wgjs_冲定额6'
-        ];
-        $data = [];
-        foreach ($arr as $key => $value){
-            if (!isset($req[$value])){
-                continue;
-            }
-            $data[$value] = $req[$value];
-        }
-        
-        if (count($data)==0){
-            $this->error('参数错误','',111);
-        }
-        $data['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
-        $data['mod_rq'] = date('Y-m-d H:i:s');
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db('db_wgjs')->where('UniqId',$req['UniqId'])->fetchSql(true)->update($data);
-            $bool = db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-      /**
-     * 新增
-     * @ApiMethod POST
-    */
-    public function add()
-    {
-        if(!$this->request->isPost()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) || !isset($req['sys_id']) ){
-            $this->error('参数错误');
-        }
-        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1']) || empty($req['sys_id'])){
-            $this->error('参数不能为空');
-        }
-        $UniqId = db()->table('db_wgjs')->order('UniqId desc')->value('UniqId');
-        if ($UniqId < 1000000){
-            $UniqId = 1000000;
-        }else{
-            $UniqId = $UniqId + 1;
-        }
-        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
-        $req['sys_rq'] = date('Y-m-d H:i:s');
-        $req['UniqId'] = $UniqId;
-        $req['sys_id'] = $req['sys_id'];
-        //开启事务
-        db()->startTrans();
-        try{
-            $sql = db()->table('db_wgjs')->fetchSql(true)->insert($req);
-            $res= db()->query($sql);
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($res===false) $this->error('失败');
-
-        $this->success('成功');
-    }
-    /**
-     * 删除
-     * @ApiMethod (GET)
-     * @param string $wgjs_rq 日期
-     * @param string $wgjs_bh1 员工编号
-    */
-    public function del(){
-        //get请求
-        if(!$this->request->isGet()){
-            $this->error('请求方式错误');
-        }
-        $req = $this->request->param();
-
-        if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
-            $this->error('参数错误','UniqId',100);
-        }
-
-        //开启事务
-        db()->startTrans();
-        try{
-            $bool = db('db_wgjs')->where('UniqId',$req['UniqId'])->delete();
-            // 提交事务
-            db()->commit();
-        } catch (\Exception $e) {
-            // 回滚事务
-            db()->rollback();
-            $this->error($e->getMessage());
-        }
-
-        if($bool===false) $this->error('失败');
-
-        $this->success('成功');
- 
-    }
-
-}

+ 0 - 24
application/api/controller/Process.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use \think\Request;
-use \think\Db;
-
-/**
- * 工序损耗管理接口
- */
-class Process extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-    /**
-     * 首页
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-
-}

+ 0 - 196
application/api/controller/ProcessDocument.php

@@ -1,196 +0,0 @@
-<?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use \think\Request;
-use \think\Db;
-/**
- * 流程单接口
- */
-class ProcessDocument extends Api
-{
-    protected $noNeedLogin = ['*'];
-    protected $noNeedRight = ['*'];
-
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
-    }
-    /**
-     * 获取工单基本数据
-     *
-     * @ApiMethod GET
-     * @params string order
-    */
-    public function getData(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        $order = $params['order'];
-        if (!isset($order)){
-            $this->error('参数不能为空');
-        }
-        $map = array();
-        $map['a.Gd_gdbh'] = $order;
-        //胶印车间计量单位为”张“,凹印车间计量单位一般为”吨“
-        $info = db('工单_基本资料')->alias('a')
-            ->join('工单_bom资料 b ',' a.Gd_gdbh=b.BOM_工单编号 AND a.行号 = b.BOM_工单行号','left')
-            ->field('DISTINCT(b.BOM_物料名称),a.成品代号,a.产品版本号,b.BOM_计划用量')
-            ->where($map)
-            ->where('b.BOM_产出单位',['eq','张'],['eq','吨'],'or')
-            ->select();
-        if(empty($info)){
-            $this->success('请求成功');
-        }
-        $res =array();
-
-        $res['yjData'] = \db('工单_印件资料')->where('Yj_gdbh',$order)->field('yj_Yjno,yj_Yjdh,yj_yjmc')->order('yj_Yjno')->select();
-        if (count($info) > 1){
-            foreach ($info as $k=>$v){
-                $str = rtrim($v['BOM_物料名称']);
-                $res['paper'][$k] ['bom_物料名称'] =  $str;
-                $res['paper'][$k] ['产品版本号'] =  rtrim($v['产品版本号']);
-                $res['paper'][$k] ['bom_计划用量'] = intval($v['BOM_计划用量']);
-            }
-        }else{
-            $res['paper'][0]['bom_物料名称'] = rtrim($info[0]['BOM_物料名称']);
-            $res['paper'][0]['产品版本号'] = rtrim($info[0]['产品版本号']);
-            $res['paper'][0]['bom_计划用量'] = intval($info[0]['BOM_计划用量']);
-        }
-        $res['num'] = count($info);
-        $this->success('请求成功',$res);
-    }
-    /**
-     * 获取历史工艺信息
-     *
-     * @ApiMethod GET
-     * @params string order
-    */
-    public function getHistory(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        if (!isset($params['yjdh'])){
-            $this->error('参数不能为空');
-        }
-        $where = array();
-        //印件代号
-        $where['product_number'] = $params['yjdh'];
-        $db2 = \db()->connect(config('database.db2'));
-        $res = $db2->name('qr_history')->where($where)->order('id desc')->field('data,update')->find();
-        $result = array();
-        $result['update'] = '暂无';
-        $result['data'] = '';
-        $result['num'] = 0;
-        $result['department'] = '车间';
-        if ($res){
-            $data = explode(',',$res['data']);
-            $result['num'] = 1;
-            $result['data'] = $data;
-            $result['update'] = $res['update'];
-        }
-        $this->success('请求成功',$result);
-    }
-    /**
-     * 保存产品工艺信息
-     *
-     * @ApiMethod POST
-     * @params
-    */
-    public function saveData(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-
-        if (empty($params['order'])){
-            $this->error('参数不能为空');
-        }
-        $db2 = \db()->connect(config('database.db2'));
-        $ip = request()->ip();
-        //定义各部门ip地址
-        $JYarray=array('20.0.3.253','60.190.242.28','127.0.0.1');
-        $WYarray=array('20.0.3.110','60.190.242.26');
-        $MQarray=array('20.0.2.200','60.190.242.29');
-        $department = -1;
-        //确认是不是凹印车间,ip确认部门不准
-        $explode_data = explode(',',$params['data']);
-        if (in_array($ip,$MQarray)){
-            $department = 3;
-        }elseif (in_array($ip,$WYarray) || $explode_data[0] == '卷凹' || $explode_data[0] == '凹印'){
-            $department = 2;
-        }else{
-            $department = 1;
-        }
-        $data = [];
-        $data['department'] = $department;
-        $data['data'] = substr($params['data'],0,-1);
-        $data['product_number'] = rtrim($params['yjdh']);
-        $map['product_number'] = $data['product_number'];
-        $data['update'] = date('Y-m-d H:i:s');
-        $data['ip'] =$ip;
-        $isNull = $db2->name('qr_history')->where($map)->find();
-        if ($isNull){//去更新工艺及时间
-            $res = $db2->name('qr_history')->where('id',$isNull['id'])->update($data);
-        }else{//新增
-            $res = $db2->name('qr_history')->insert($data);
-        }
-        if ($res){
-            $this->success('更新成功');
-        }else{
-            $this->error('更新失败');
-        }
-    }
-    /**
-     * 获取流程单头部信息
-     *
-     * @ApiMethod POST
-     * @params string order
-    */
-    public function getInfo(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $data = Request::instance()->param();
-        if (!isset($data['order'])){
-            $this->error('参数不能为空');
-        }
-        $str = '原纸';
-        $where = [
-            'Gd_gdbh'=> $data['order'],
-            'Gd_cpmc'=> $data['yjmc']
-        ];
-        $field  = 'Gd_gdbh,rtrim(销售订单号) as 销售订单号,rtrim(Gd_cpmc) as Gd_cpmc,rtrim(成品名称) as 成品名称,计划投料,实际投料,rtrim(产品版本号) as 产品版本号,rtrim(警语版面) as 警语版面,
-        rtrim(Gd_desc) as Gd_desc';
-        $gdinfo =  db('工单_基本资料')
-            ->where($where)
-            ->field($field)
-            ->select();
-        $length = count($gdinfo);
-        if (!empty($data['num'])){
-            $gdinfo[0]['计划投料'] = $data['num'];
-        }
-        if (rtrim($gdinfo[0]['成品名称']) == ''){
-            $cpmc = trim($gdinfo[0]['Gd_cpmc']);
-            $gdinfo[0]['成品名称'] = $cpmc;
-        }
-        $gdinfo[0]['mabao'] = $data['mabao'];
-        $gdinfo[0]['version'] = $data['version'];
-        $gdinfo[0]['liucheng_num'] = '';
-
-        $newdata = explode(',',$data['string']);
-
-        $gdinfo['gy_data'] = array_filter($newdata);
-        $gdinfo['technique_sequence'] = trim($gdinfo[0]['version']).'、'.trim($gdinfo[0]['警语版面']).'、'.trim($gdinfo[0]['Gd_desc']);
-        $gdinfo['total_liuchen'] = ceil(($gdinfo[0]['计划投料']?$gdinfo[0]['计划投料']:$gdinfo[0]['实际投料']*10000)/$data['tldx']); //总的流程数
-        $gdinfo['length'] = $length;
-        $this->success('请求成功',$gdinfo);
-    }
-}