Эх сурвалжийг харах

新增接口及优化接口

huangsanjia 1 жил өмнө
parent
commit
54061b7b51

+ 20 - 12
application/api/controller/OtherCountDocument.php

@@ -96,23 +96,26 @@ class OtherCountDocument extends Api
 
         $where = [];
         if (isset($req['date']) && !empty($req['date'])){
-            $where['Sczl_rq'] = ['LIKE',$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['Sczl_bh1'] = $req['Sczl_bh1'];
-        if (isset($req['order']) && !empty($req['order'])) $where['Sczl_gdbh'] = $req['order'];
+        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_拉料计件')
-            ->field('rtrim(sczl_Type) as sczl_Type, LEFT(Sczl_rq, 10) as Sczl_rq, Sczl_bh1, sczl_gdbh, CAST(Sczl_cl AS SIGNED) as Sczl_cl,
-            rtrim(Sczl_desc) as Sczl_desc, rtrim(Sczl_gxmc) as Sczl_gxmc, sczl_yjno, sczl_gxh, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
+        $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('Sczl_rq asc, UniqId asc')
+            ->order('a.Sczl_rq asc, a.UniqId asc')
             ->select();
 
-        $total = db()->table('db_拉料计件')->where($where)->count();
+        $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) {
@@ -146,10 +149,12 @@ class OtherCountDocument extends Api
             $this->error('参数错误');
         }
 
-        $rows = db()->table('db_拉料计件')->alias('d')
-            ->field('d.*, ')
-            ->join('工单_基本资料 g', 'd.')
-            ->where('d.UniqId',$UniqId)
+        $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();
 
 
@@ -205,4 +210,7 @@ class OtherCountDocument extends Api
         }
         $this->success('请求成功',$data);
     }
+
+
+
 }

+ 223 - 5
application/api/controller/WorkOrderVerification.php

@@ -158,8 +158,15 @@ class WorkOrderVerification extends Api
         if (!isset($params['UniqId']) || empty($params['UniqId'])){
             $this->error('参数错误');
         }
-        $field = '';
-        $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->find();
+        $field = 'qczl_gdbh,qczl_Pygd,qczl_yjno,qczl_gxh,qczl_gxmc,qczl_type,qczl_rq,qczl_num,qczl_fp,
+        qczl_NumDesc,qczl_NumDesc1,qczl_NumDesc2,qczl_NumDesc3,qczl_NumDesc4,qczl_NumDesc5,qczl_NumDesc6,qczl_NumDesc7,qczl_NumDesc8,
+        fp_lb1,fp_lb2,fp_lb3,fp_lb4,fp_lb5,fp_lb6,fp_lb7,fp_lb8,fp_lb9,fp_lb10,fp_lb11,fp_lb12,fp_lb13,trim(fp_lb14) as fp_lb14,trim(fp_lb15) as fp_lb15,trim(fp_lb16) as fp_lb16,trim(fp_lb17) as fp_lb17,
+        fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,fp_sl14,fp_sl15,fp_sl16,fp_sl17
+        fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
+        fp_bz1,fp_bz2,fp_bz3,fp_bz4,fp_bz5,fp_bz6,fp_bz7,fp_bz8,fp_bz9,fp_bz10,fp_bz11,fp_bz12,fp_bz13,
+        fp_gxmc1,fp_gxmc2,fp_gxmc3,fp_gxmc4,fp_gxmc5,fp_gxmc6,fp_gxmc7,fp_gxmc8,fp_gxmc9,fp_gxmc10,fp_gxmc11,fp_gxmc12,fp_gxmc13,
+        sys_id,rtrim(sys_rq) as sys_rq,UniqId';
+        $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->field($field)->find();
         $list['fp_name1'] = '';
         if (!empty($list['fp_bh1'])){
             $list['fp_name1'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh1'])->value('rtrim(员工姓名)');
@@ -476,7 +483,7 @@ class WorkOrderVerification extends Api
         $this->success('请求成功',$gdInfo);
     }
     /**
-     * 工单工期异常调整
+     * 获取工单工序状态
      * @ApiMethod GET
      * @params string order
      * 计划产量计算方式:上个工序计划产量-(基础损耗+损耗率*上个工序计划产量)*损耗系数*计损色数)
@@ -497,16 +504,17 @@ class WorkOrderVerification extends Api
             ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh and a.Gy0_gxh = b.sczl_gxh','left')
             ->where($where)
             ->field('a.Gy0_yjno,a.Gy0_gxh,rtrim(a.Gy0_gxmc) as Gy0_gxmc,a.Gy0_sbbh,a.Gy0_Rate0,a.Gy0_Rate1,a.损耗系数 as Gy0_Rate3,a.Gy0_Ms,a.Gy0_SITE,a.Gy0_计划接货数,a.PD_WG,
-            sum(b.sczl_cl) as cl')
+            a.UniqId,sum(b.sczl_cl) as cl')
             ->group('a.Gy0_gxh')
             ->select();
         $lastNum = $productNum;
         $res = [];
         foreach ($gyData as $key=> $process) {
+            $res[$key]['UniqId'] = $process['UniqId'];
             $res[$key]['Gy0_yjno'] = $process['Gy0_yjno'] > 10 ? $process['Gy0_yjno'] : '0'.$process['Gy0_yjno'];
             $res[$key]['Gy0_gxh'] = $process['Gy0_gxh'] > 10 ? $process['Gy0_gxh'] : '0'.$process['Gy0_gxh'];
             $res[$key]['Gy0_gxmc'] = $process['Gy0_gxmc'];
-            $res[$key]['Gy0_sbbh'] = $process['Gy0_sbbh'];
+            $res[$key]['Gy0_sbbh'] = rtrim($process['Gy0_sbbh']);
             $res[$key]['PD_WG'] = $process['PD_WG'];
             $res[$key]['finish'] = empty($process['cl']) ? 0: (int)$process['cl'];
             // 计算工序计划产量
@@ -542,4 +550,214 @@ class WorkOrderVerification extends Api
         }
         $this->success('请求成功',$res);
     }
+    /**
+     * 工单工序状态更正
+     * @ApiMethod POST
+     * @params string UniqId
+     * @params string date
+    */
+    public function editOrderFinishDate(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (!isset($params['UniqId']) || !isset($params['date'])){
+            $this->error('参数错误');
+        }
+        if (empty($params['UniqId'])){
+            $this->error('参数不能为空');
+        }
+        if (empty($params['date'])){
+            $params['date'] = '1900-01-01 00:00:00';
+        }
+        $res = Db::name('工单_工艺资料')->where('UniqId',$params['UniqId'])->setField('PD_WG',$params['date']);
+        if ($res != false){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 工单工序生产进程菜单栏
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function getOrderProcessLeft(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])){
+            $this->error('参数错误');
+        }
+        $where['Gd_gdbh'] = $params['order'];
+        $where['行号'] = 1;
+        //工单基本资料
+        $info = Db::name('工单_基本资料')->where($where)->field('rtrim(成品代号)  as code,rtrim(成品名称) as name')->find();
+        //工艺资料
+        $option['Gy0_gdbh'] = $params['order'];
+        $gyInfo = Db::name('工单_工艺资料')
+            ->where($option)
+            ->where(function ($query) {
+                $query->where('Gy0_sbbh', '<>', '')
+                    ->whereOr('Gy0_gxmc', '核检')
+                    ->whereOr('Gy0_gxmc', '成品防护');
+            })
+            ->field('Gy0_yjno,Gy0_gxh')
+            ->select();
+        foreach ($gyInfo as $key=>$value){
+            $gyInfo[$key]['Gy0_yjno'] = $value['Gy0_yjno'] > 10 ? $value['Gy0_yjno'] : '0'.$value['Gy0_yjno'];
+            $gyInfo[$key]['Gy0_gxh'] = $value['Gy0_gxh'] > 10 ? $value['Gy0_gxh'] : '0'.$value['Gy0_gxh'];
+        }
+        $res['Gd_info'] = $info;
+        $res['Gy_info'] = $gyInfo;
+        $this->success('请求成功',$res);
+    }
+    /**
+     * 工单工序生产进程右侧
+     * @ApiMethod GET
+     * @params string order
+     * @params string gxNo
+    */
+    public function getOrderProcessRight(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])){
+            $this->error('参数错误');
+        }
+        if (!isset($params['gxNo']) || empty($params['gxNo'])){
+            $this->error('参数错误');
+        }
+        $total = Db::name('设备_产量计酬')->where('sczl_gdbh',$params['order'])->order('sczl_num')->column('distinct(sczl_num)');
+        $where['sczl_gxh'] = (int)$params['gxNo'];
+        $where['sczl_gdbh'] = $params['order'];
+        $process = Db::name('设备_产量计酬')->where($where)->order('sczl_num')->column('distinct(sczl_num)');
+        $res['total_process'] = $total;
+        $res['process'] = $process;
+        $this->success('请求成功',$res);
+    }
+    /**
+     * 核检废品日统计
+     * @ApiMethod GET
+     * @params date start_date
+     * @params date end_date
+    */
+    public function getDaysWast()
+    {
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['start_date']) || empty($params['start_date'])) {
+            $this->error('参数错误');
+        }
+        if (!isset($params['end_date']) || empty($params['end_date'])) {
+            $this->error('参数错误');
+        }
+        $where['qczl_rq'] = array('between time', [$params['start_date'], $params['start_date']]);
+        $field = '
+        rtrim(fp_lb1) as fp_lb1,rtrim(fp_lb2) as fp_lb2,rtrim(fp_lb3) as fp_lb3,rtrim(fp_lb4) as fp_lb4,rtrim(fp_lb5) as fp_lb5,rtrim(fp_lb6) as fp_lb6,rtrim(fp_lb7) as fp_lb7,
+        rtrim(fp_lb8) as fp_lb8,rtrim(fp_lb9) as fp_lb9,rtrim(fp_lb10) as fp_lb10,rtrim(fp_lb11) as fp_lb11,rtrim(fp_lb12) as fp_lb12,rtrim(fp_lb13) as fp_lb13,
+        fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
+        fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
+        rtrim(fp_bz1) as fp_bz1, rtrim(fp_bz2) as fp_bz2, rtrim(fp_bz3) as fp_bz3, rtrim(fp_bz4) as fp_bz4, rtrim(fp_bz5) as fp_bz5, rtrim(fp_bz6) as fp_bz6, rtrim(fp_bz7) as fp_bz7,
+        rtrim(fp_bz8) as fp_bz8, rtrim(fp_bz9) as fp_bz9, rtrim(fp_bz10) as fp_bz10, rtrim(fp_bz11) as fp_bz11, rtrim(fp_bz12) as fp_bz12, rtrim(fp_bz13) as fp_bz13,
+        qczl_rq
+        ';
+
+        $data = Db::name('db_qczl')
+            ->where($where)
+            ->where(function ($query) {
+                for ($i = 1; $i <= 13; $i++) {
+                    $query->whereOr("fp_lb$i", 'like', '%K%','AND',"fp_sl$i",'>',0);
+                }
+            })
+            ->field($field)->select();
+        $list = [];
+        $j = 0;
+        foreach ($data as $entry) {
+            for ($i = 1; $i <= 13; $i++) {
+                $labelKey = "fp_lb" . $i;
+                $slKey = "fp_sl" . $i;
+                $bhKey = "fp_bh" . $i;
+                $bzKey = "fp_bz" . $i;
+                if (!empty($entry[$labelKey])) {
+                    if ((substr($entry[$labelKey],0,3) == 'K02' || substr($entry[$labelKey],0,3) == 'K01') && $entry[$slKey] != '0'){
+                        $list[$j]['fp_lb'] = $entry[$labelKey];
+                        $list[$j]['fp_sl'] = $entry[$slKey];
+                        $list[$j]['fp_bh'] = $entry[$bhKey];
+                        $name = Db::name('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
+                        $list[$j]['fp_name'] = empty($name) ? '计时工' : $name;
+                        $list[$j]['fp_bz'] = $entry[$bzKey];
+                        $list[$j]['qczl_rq'] = $entry['qczl_rq'];
+                        $j++;
+                    }
+                }
+            }
+        }
+        $resultArray = array();
+        foreach ($list as $item) {
+            $found = false;
+            foreach ($resultArray as &$resultItem) {
+                if ($item["fp_lb"] === $resultItem["fp_lb"] && $item["fp_bh"] === $resultItem["fp_bh"]) {
+                    $resultItem["fp_sl"] += (int)$item["fp_sl"];
+                    $found = true;
+                    break;
+                }
+            }
+            if (!$found) {
+                $resultArray[] = $item;
+            }
+        }
+        // 使用usort进行排序
+        usort($resultArray, function($a, $b) {
+            // First, sort by fp_lb (K01/K02)
+            $compareLb = strcmp($a['fp_lb'], $b['fp_lb']);
+            if ($compareLb !== 0) {
+                return $compareLb;
+            }
+
+            // If fp_lb is the same, prioritize B班 over A班
+            $compareBz = strcmp($a['fp_bz'], $b['fp_bz']);
+            if ($compareBz !== 0) {
+                return (trim($a['fp_bz']) === 'B班') ? -1 : 1;
+            }
+
+            // If fp_bz is the same, sort by fp_bh
+            $compareBh = strcmp($a['fp_bh'], $b['fp_bh']);
+            return $compareBh;
+        });
+        $this->success('请求成功',$resultArray);
+    }
+    /**
+     * 月度核检废品责任人统计
+     * @ApiMethod GET
+     * @params string date
+    */
+    public function getMonthPeopleTotal(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['date']) || empty($params['date'])) {
+            $this->error('参数错误');
+        }
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 }