liuhairui 1 год назад
Родитель
Сommit
754513f943

+ 348 - 66
application/api/controller/LargeWasteRewardPunish.php

@@ -5,6 +5,7 @@ namespace app\api\controller;
 use app\common\controller\Api;
 use think\db;
 use think\Request;
+use function fast\e;
 
 /**
  * 工序大废品惩奖记录接口
@@ -34,17 +35,24 @@ class LargeWasteRewardPunish extends Api
             $this->error('请求方式错误');
         }
         $rows = db()->table('db_大废品')
-            ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
+            ->field('DISTINCT(LEFT(sys_rq, 7)) AS mouth,LEFT(sys_rq, 10) as date, COUNT(*) as counts')
             ->group('date')
             ->order('UniqId desc')
             ->limit(40)
             ->select();
 
-
+        $list = [];
         foreach($rows as $key=>$value){
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
+            if (!isset($list[$value['mouth']])){
+                $list[$value['mouth']] = [];
+            }
+            $arr['date'] = str_replace('-', '.', $rows[$key]['date']);
+            $arr['counts'] = $rows[$key]['counts'];
+            array_push($list[$value['mouth']],$arr);
+//            $list[$value['mouth']]['date'] = str_replace('-', '.', $rows[$key]['date']);
+
         }
-        $this->success('成功',$rows);
+        $this->success('成功',$list);
     }
 
     /**
@@ -82,50 +90,62 @@ class LargeWasteRewardPunish extends Api
             $this->error('请求方式错误');
         }
         $req = $this->request->param();
-
+        $rq = $req['date'];
         $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 = substr($req['date'],0,10);
+        $req['date'] = str_replace('.','-',$date);
         $where = [];
         if (isset($req['date']) && !empty($req['date'])){
-            $where['sys_rq'] = ['LIKE',$req['date'].'%'];
+            if (preg_match('/[\x{4e00}-\x{9fa5}]/u', $rq)>0){
+                $where['sys_rq'] = ['LIKE',$req['date'].'%'];
+            }else{
+                $where['sczl_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();
+            ->field('sczl_gdbh, LEFT(sczl_rq, 10) as sczl_rq, rtrim(sczl_numDesc) as sczl_numDesc, sczl_ls, sczl_yjno, 
+        rtrim(责任部门) as 责任部门,sczl_cl, 
+        rtrim(sczl_fplxA) as sczl_fplxA, sczl_fplxB, jl_jtbh as Jl_bzdh, JL_bh1, 
+        sczl_jtbh as sczl_bzdh, sczl_bh1, sczl_je1, sczl_bh2, sczl_je2, 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();
+                ->field('sczl_gdbh, LEFT(sczl_rq, 10) as sczl_rq, rtrim(sczl_numDesc) as sczl_numDesc, sczl_ls, sczl_yjno, 
+            rtrim(责任部门) as 责任部门, sczl_cl, 
+            rtrim(sczl_fplxA) as sczl_fplxA, sczl_fplxB, jl_jtbh as Jl_bzdh, JL_bh1, 
+            sczl_jtbh as sczl_bzdh, sczl_bh1, sczl_je1, sczl_bh2, sczl_je2, 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('员工编号, 员工姓名');
+        $rs = db()->table('人事_基本资料')->where('员工姓名','<>','通用编号')->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 ? '制程废' : '';
+            if ($rows[$key]['sczl_bh1'] != '' && $value['sczl_je1'] > 0){
+                $rows[$key]['sczl_bh1'] = $rows[$key]['sczl_bh1'].'(-'.$value['sczl_je1'].')';
+            }
+            if ($rows[$key]['sczl_bh2'] != '' && $value['sczl_je2'] > 0){
+                $rows[$key]['sczl_bh2'] = $rows[$key]['sczl_bh2'].'(-'.$value['sczl_je2'].')';
+            }
             unset($rows[$key]['sczl_yjno']);
         }
 
@@ -158,37 +178,37 @@ class LargeWasteRewardPunish extends Api
             ->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(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(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')
+            ->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);
@@ -292,10 +312,34 @@ class LargeWasteRewardPunish extends Api
         if ($this->request->isGet() === false){
             $this->error('非法请求');
         }
-        $list = \db('设备_基本资料')
-            ->field('rtrim(设备编号) as 设备编号')
-            ->where('sys_sbID','<>','')
+        $param = $this->request->param();
+        $list = \db('设备_产量计酬')
+            ->alias('a')
+            ->join('人事_基本资料 b1','a.sczl_bh1 = b1.员工编号','left')
+            ->join('人事_基本资料 b2','a.sczl_bh2 = b2.员工编号','left')
+            ->join('人事_基本资料 b3','a.sczl_bh3 = b3.员工编号','left')
+            ->join('人事_基本资料 b4','a.sczl_bh4 = b4.员工编号','left')
+            ->join('人事_基本资料 b5','a.sczl_bh5 = b5.员工编号','left')
+            ->join('人事_基本资料 b6','a.sczl_bh6 = b6.员工编号','left')
+            ->join('人事_基本资料 b7','a.sczl_bh7 = b7.员工编号','left')
+            ->join('人事_基本资料 b8','a.sczl_bh8 = b8.员工编号','left')
+            ->join('人事_基本资料 b9','a.sczl_bh9 = b9.员工编号','left')
+            ->join('人事_基本资料 b10','a.sczl_bh10 = b10.员工编号','left')
+            ->field('a.sczl_gxmc as 工序名称,a.sczl_jtbh as 机台编号,a.sczl_bh1 as 员工编号1,rtrim(b1.员工姓名) as 员工姓名1
+            ,a.sczl_bh2 as 员工编号2,rtrim(b2.员工姓名) as 员工姓名2,a.sczl_bh3 as 员工编号3,rtrim(b3.员工姓名) as 员工姓名3
+            ,a.sczl_bh4 as 员工编号4,rtrim(b4.员工姓名) as 员工姓名4,a.sczl_bh5 as 员工编号5,rtrim(b5.员工姓名) as 员工姓名5
+            ,a.sczl_bh6 as 员工编号6,rtrim(b6.员工姓名) as 员工姓名6,a.sczl_bh7 as 员工编号7,rtrim(b7.员工姓名) as 员工姓名7
+            ,a.sczl_bh8 as 员工编号8,rtrim(b8.员工姓名) as 员工姓名8,a.sczl_bh9 as 员工编号9,rtrim(b9.员工姓名) as 员工姓名9
+            ,a.sczl_bh10 as 员工编号10,rtrim(b10.员工姓名) as 员工姓名10')
+            ->where('a.sczl_gdbh',$param['gdbh'])
+            ->where('a.sczl_yjno',$param['yjno'])
+            ->where('a.sczl_bzdh','like',substr($param['bzdh'],0,1).'%')
+            ->group('机台编号,员工编号1,员工编号2,员工编号3,员工编号4,员工编号5,员工编号6,员工编号7,员工编号8,员工编号9,员工编号10')
             ->select();
+//        $list = \db('设备_基本资料')
+//            ->field('rtrim(设备编号) as 设备编号')
+//            ->where('sys_sbID','<>','')
+//            ->select();
         if (empty($list)){
             $this->success('未找到机台编号');
         }
@@ -359,28 +403,149 @@ class LargeWasteRewardPunish extends Api
      */
     public function JunkDetailEdit()
     {
-        if (Request::instance()->isPost() === false){
+        // 判断请求方式是否为 POST
+        if (Request::instance()->isPost() === false) {
             $this->error('非法请求');
         }
+
+        // 获取请求参数
         $param = Request::instance()->post();
-        if (empty($param['sczl_gdbh']) || empty($param['UniqId'])){
+        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']);
+
+        $param['mod_rq'] = date('Y-m-d H:i:s', time());
+
+        $data = $param['sczl_rq'].' 00:00:00';
+
+        // 奖励班组封顶限制【记录是否存在超限的标志】
+        $over_limit = false;
+
+        // 遍历 JL_bh1 ~ JL_bh10,检查当天和本月金额限制
+        for ($i = 1; $i <= 10; $i++) {
+            $jl_bh = 'JL_bh' . $i;  // 获取 JL_bh1 到 JL_bh10
+            $jl_je = 'JL_Je' . $i;  // 获取 JL_Je1 到 JL_Je10
+
+            if (!empty($param[$jl_bh]) && isset($param[$jl_je])) {  // 确保 JL_bh 和 JL_Je 不为空
+                $person_id = $param[$jl_bh];  // 当前人员的 ID
+                $amount = $param[$jl_je];     // 当前人员的金额
+
+                // 获取当天的所有记录金额总和
+                $daily_total = \db('db_大废品')
+                    ->where('sczl_rq', $data)
+                    ->sum($jl_je);
+
+
+                $daUniqId = \db('db_大废品')
+                    ->where('UniqId', $param['UniqId'])
+                    ->sum($jl_je);
+
+                // 将当天的金额总和与接口传过来的金额加起来
+                $total_amount = ($daily_total + $amount) - $daUniqId;  // 假设传入的是 JL_Je1
+
+
+                // 检查金额是否超过 200 元
+                if ($total_amount > 200) {
+                    $this->error("【{$person_id}】当天金额超限!当天金额不能超过 200 元!");
+                    $over_limit = true;
+                    break;
+                }
+
+                // 获取当月的所有记录金额总和
+                $month = substr($data, 5, 2);
+                $year = substr($data, 0, 4);
+                $start_date = $year . '-' . $month . '-01';
+                $end_date = date('Y-m-t', strtotime($start_date));
+                $monthly_total = \db('db_大废品')
+                    ->whereBetween('sczl_rq', [$start_date, $end_date])
+                    ->where($jl_bh, $person_id)
+                    ->sum($jl_je);
+
+                // 检查本月是否超过 1500 元
+                if ($monthly_total + $amount - $daUniqId > 1500) {
+                    $this->error("【{$person_id}】本月金额超限!本月金额不能超过 1500 元!");
+                    $over_limit = true;
+                    break;
+                }
+            }
+        }
+        // 如果存在超限,停止执行
+        if ($over_limit) {
+            return;
+        }
+
+        // 扣罚金额封顶限制
+        $kfover_limit = false;
+        // 检查 sczl_bh1 的限制(不能超过 1000 元)
+        if (!empty($param['sczl_bh1']) && isset($param['sczl_je1'])) {
+            $person_id = $param['sczl_bh1'];
+            $amount = $param['sczl_je1'];
+
+            // 获取该人员当天的扣罚金额总和
+            $daily_total = \db('db_大废品')
+                ->where('sczl_rq', $data)
+                ->where('sczl_bh1', $person_id)
+                ->sum('sczl_je1');
+
+            $daUniqId = \db('db_大废品')
+                ->where('UniqId', $param['UniqId'])
+                ->sum("sczl_je1");
+
+            // 判断是否超过 1000 元
+            if (($daily_total + $amount) - $daUniqId > 1000) {
+                $this->error("【{$person_id}】当天扣罚金额超限!当天扣罚金额不能超过 1000 元!");
+                $kfover_limit = true;
+            }
+        }
+
+        // 遍历 sczl_bh2 ~ sczl_bh10,检查当天金额是否超过 500 元
+        for ($i = 2; $i <= 10; $i++) {
+            $sczl_bh = 'sczl_bh' . $i;
+            $sczl_je = 'sczl_je' . $i;
+
+            if (!empty($param[$sczl_bh]) && isset($param[$sczl_je])) {
+                $person_id = $param[$sczl_bh];
+                $amount = $param[$sczl_je];
+
+                // 获取该人员当天的扣罚金额总和
+                $daily_total = \db('db_大废品')
+                    ->where('sczl_rq', $data)
+//                    ->where($sczl_bh, $person_id)
+                    ->sum($sczl_je);
+
+                $daUniqId = \db('db_大废品')
+                    ->where('UniqId', $param['UniqId'])
+                    ->sum($sczl_je);
+
+                $total_amount = ($daily_total + $amount) - $daUniqId;  // 假设传入的是 JL_Je1
+
+                // 判断是否超过 500 元
+                if ($total_amount > 500) {
+                    $this->error("【{$person_id}】当天扣罚金额超限!当天扣罚金额不能超过 500 元!");
+                    $kfover_limit = true;
+                    break;  // 如果超限,停止检查
+                }
+            }
+        }
+
+        // 如果超限就不插入数据
+        if ($kfover_limit) {
+            return;  // 直接终止
+        }
+        // 执行更新操作
+//        unset($data['UniqId']);
         $sql = \db('db_大废品')
-            ->where('UniqId',$param['UniqId'])
+            ->where('UniqId', $param['UniqId'])
             ->fetchSql(true)
-            ->update($data);
+            ->update($param);
         $res = \db()->query($sql);
-        if ($res !== false){
+
+        if ($res !== false) {
             $this->success('修改成功');
-        }else{
-            $this->error('失败');
+        } else {
+            $this->error('修改失败');
         }
     }
-
     /**
      * 大废品数据添加
      * @return void
@@ -389,26 +554,143 @@ class LargeWasteRewardPunish extends Api
      */
     public function JunkDetailAdd()
     {
-        if (Request::instance()->isPost() === false){
+        // 非POST请求不允许提交
+        if (Request::instance()->isPost() === false) {
             $this->error('非法请求');
         }
+
         $param = Request::instance()->post();
-        if (empty($param['sczl_gdbh'])){
+
+        // 检查是否传入必要的参数
+        if (empty($param['sczl_gdbh'])) {
             $this->error('参数错误');
         }
+
+        // 获取最后一条记录的UniqId
         $lastID = \db('db_大废品')->order('UniqId desc')->value('UniqId');
-        $param['sys_rq'] = date('Y-m-d H:i:s',time());
+
+        // 设置当前时间和其他初始化数据
+        $param['sys_rq'] = date('Y-m-d H:i:s', time());
         $param['mod_rq'] = '1900-01-01 00:00:00';
         $param['UniqId'] = $lastID + 1;
+
+        $data = $param['sczl_rq'];
+
+
+        //奖励班组封顶限制【记录是否存在超限的标志】
+        $over_limit = false;
+        // 遍历参数,检查每个人当天和本月的消费情况
+        for ($i = 1; $i <= 10; $i++) {
+            $jl_bh = 'JL_bh' . $i;  // 获取 JL_bh1 到 JL_bh10
+            $jl_je = 'JL_Je' . $i;  // 获取 JL_Je1 到 JL_Je10
+
+            if (!empty($param[$jl_bh]) && isset($param[$jl_je])) {  // 确保 JL_bh 和 JL_Je 不为空
+                $person_id = $param[$jl_bh];  // 获取当前人的 ID
+                $amount = $param[$jl_je];     // 当前人的金额
+
+                // 获取当天的所有记录金额总和
+                $daily_total = \db('db_大废品')
+                    ->where('sczl_rq', $data)
+                    ->where($jl_bh, $person_id)
+                    ->sum($jl_je);
+
+                // 获取当月的所有记录金额总和
+                $month = substr($data, 5, 2);
+                $year = substr($data, 0, 4);
+                $start_date = $year . '-' . $month . '-01';
+                $end_date = date('Y-m-t', strtotime($start_date));
+                $monthly_total = \db('db_大废品')
+                    ->whereBetween('sczl_rq', [$start_date, $end_date])
+                    ->where($jl_bh, $person_id)
+                    ->sum($jl_je);
+
+
+                // 检查当天是否超过 200
+                if ($daily_total + $amount > 200) {
+                    $this->error("【{$person_id}】当天金额超限!当天金额不能超过200元!");
+                    $over_limit = true;
+                    break;
+                }
+
+                // 检查本月是否超过 1500
+                if ($monthly_total + $amount > 1500) {
+                    $this->error("【{$person_id}】本月金额超限!本月金额不能超过1500元!");
+                    $over_limit = true;
+                    break;
+                }
+            }
+        }
+
+        // 如果超限就不插入数据
+        if ($over_limit) {
+            // 提示超限后停止执行
+            return;
+        }
+
+
+        // 记录是否存在超限
+        $kfover_limit = false;
+
+        // 获取 sczl_bh1 的值,并检查它是否存在
+        if (!empty($param['sczl_bh1']) && isset($param['sczl_je1'])) {
+            $person_id = $param['sczl_bh1'];
+            $amount = $param['sczl_je1'];
+
+            // 获取该人员当天的扣罚金额总和
+            $daily_total = \db('db_大废品')
+                ->where('sczl_rq', $data)
+                ->where('sczl_bh1', $person_id)
+                ->sum('sczl_je1');
+
+            // 判断是否超过 1000
+            if ($daily_total + $amount > 1000) {
+                $this->error("【{$person_id}】当天扣罚金额超限!当天扣罚金额不能超过 1000 元!");
+                $kfover_limit = true;
+            }
+        }
+        // 遍历 sczl_bh2 ~ sczl_bh10
+        for ($i = 2; $i <= 10; $i++) {
+            $sczl_bh = 'sczl_bh' . $i;
+            $sczl_je = 'sczl_je' . $i;
+
+            if (!empty($param[$sczl_bh]) && isset($param[$sczl_je])) {
+                $person_id = $param[$sczl_bh];
+                $amount = $param[$sczl_je];
+
+                // 获取该人员当天的扣罚金额总和
+                $daily_total = \db('db_大废品')
+                    ->where('sczl_rq', $data)
+                    ->where($sczl_bh, $person_id)
+                    ->sum($sczl_je);
+
+                // 判断是否超过 500
+                if ($daily_total + $amount > 500) {
+                    $this->error("【{$person_id}】当天扣罚金额超限!当天扣罚金额不能超过 500 元!");
+                    $kfover_limit = true;
+                    break; // 只要有一个超限就停止检查
+                }
+            }
+        }
+
+        // 如果超限就不插入数据
+        if ($kfover_limit) {
+            return; // 直接终止
+        }
+
+
+
+        // 插入数据
         $sql = \db('db_大废品')->fetchSql(true)->insert($param);
         $res = \db()->query($sql);
-        if ($res !== false){
+
+        if ($res !== false) {
             $this->success('添加成功');
-        }else{
+        } else {
             $this->error('失败');
         }
     }
 
+
     /**
      * 大废品数据删除
      * @return void

+ 47 - 84
application/api/controller/OrderSuperLoss.php

@@ -25,7 +25,7 @@ class OrderSuperLoss extends Api
     /**
      * 获取左侧菜单栏
      * @ApiMethod GET
-    */
+     */
     public function getTab()
     {
         if (Request::instance()->isGet() == false) {
@@ -106,7 +106,7 @@ class OrderSuperLoss extends Api
      * 目标合格率 = 100%-超节损工单中显示工序的允损比例之和
      * 节损奖 小盒0.02 大盒0.09
      *
-    */
+     */
     public function getList(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -129,11 +129,10 @@ class OrderSuperLoss extends Api
         }
         if (!empty($params['search'])) {
             if (!empty($params['date']) || !empty($params['code'])) {
-               $this->error('参数错误');
+                $this->error('参数错误');
             }
             $where['a.jjcp_gdbh|a.成品名称|a.jjcp_cpmc'] = array('like','%'.$params['search'].'%');
         }
-//        $where['b.行号' ] = 1;
         $where['a.jjcp_smb' ] = array('IN', array('末 板', '末板'));
         $limit = $params['limit'];
         if (empty($limit)){
@@ -143,33 +142,14 @@ class OrderSuperLoss extends Api
         if (empty($pages)){
             $pages = 1;
         }
-//        $str = '';
-//        if (empty($params['search'])){
-//            $str = '/'.$date . '/' . $params['code'].'/'.$pages;
-//        }
-//        $is_have_cache = Cache::get('OrderSuperLoss/getList'.$str);
         $is_have_cache = false;
         $num = config('product_code_digit');
         if ($is_have_cache === false){
             if (!empty($params['code'])){
-//                $data = db('成品入仓')->alias('a')
-//                    ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
-//                    ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh AND a.jjcp_cpdh = c.yj_Yjdh','left')
-//                    ->join('物料_收发记录 d',' a.jjcp_gdbh = d.st_gdbh AND d.cpdh = a.jjcp_cpdh')
-//                    ->where($where)
-//                    ->where('d.仓库编号','Y101')
-//                    ->whereRaw('LEFT(a.成品编码, ' . $num . ') = "' . $params['code'] . '"')
-//                    ->field('DISTINCT(a.jjcp_gdbh) as Gd_gdbh,a.jjcp_yjno,rtrim(a.jjcp_cpdh) as 成品编码,rtrim(a.jjcp_cpmc) as 成品名称,a.jjcp_sj,a.jjcp_smb,b.计量单位,
-//                b.Gd_khdh, SUM(d.st_sl) as 实际投料 ,c.yj_Yjno, c.yj_ls,c.yj_ks,c.质量考核')
-//                    ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_yjno,d.st_rq desc')
-//                    ->group('a.jjcp_gdbh,a.jjcp_yjno')
-//                    ->page($pages)
-//                    ->limit($limit)
-//                    ->select();
-
                 $sql= db('物料_收发记录')
                     ->alias('d')
                     ->where('d.仓库编号', 'Y101')
+                    ->whereOr('d.仓库编号', '101')
                     ->group('d.st_gdbh, d.cpdh')
                     ->field('d.st_gdbh, d.cpdh,d.st_rq, SUM(d.st_sl) as 实际投料,d.仓库编号')
                     ->buildSql();
@@ -178,7 +158,9 @@ class OrderSuperLoss extends Api
                     ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh AND a.jjcp_cpdh = c.yj_Yjdh', 'left')
                     ->join([$sql => 'd'], 'a.jjcp_gdbh = d.st_gdbh AND a.jjcp_cpdh = d.cpdh', 'left')
                     ->where($where)
-                    ->where('d.仓库编号','Y101')
+                    ->where(function($query) {
+                        $query->where('d.仓库编号', '101')
+                            ->whereOr('d.仓库编号', 'Y101');})
                     ->whereRaw('LEFT(a.成品编码, CASE WHEN a.成品编码 REGEXP "[a-zA-Z]" THEN 5 ELSE 4 END) = ?', [$params['code']])
                     ->field('a.jjcp_gdbh as Gd_gdbh, a.jjcp_yjno, rtrim(a.jjcp_cpdh) as 成品编码, rtrim(a.jjcp_cpmc) as 成品名称,
              a.jjcp_sj, a.jjcp_smb, b.计量单位, b.Gd_khdh, d.实际投料, c.yj_Yjno, c.yj_ls, c.yj_ks, c.质量考核')
@@ -187,7 +169,6 @@ class OrderSuperLoss extends Api
                     ->page($pages)
                     ->limit($limit)
                     ->select();
-
                 $total = db('成品入仓')->alias('a')
                     ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
                     ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
@@ -195,27 +176,13 @@ class OrderSuperLoss extends Api
                     ->whereRaw('LEFT(a.成品编码, CASE WHEN a.成品编码 REGEXP "[a-zA-Z]" THEN 5 ELSE 4 END) = ?', [$params['code']])
                     ->count();
             }else{
-//                $data = db('成品入仓')->alias('a')
-//                    ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
-//                    ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh AND a.jjcp_cpdh = c.yj_Yjdh','left')
-//                    ->join('物料_收发记录 d',' a.jjcp_gdbh = d.st_gdbh AND d.cpdh = a.jjcp_cpdh')
-//                    ->where($where)
-//                    ->where('d.仓库编号','Y101')
-//                    ->field('DISTINCT(a.jjcp_gdbh) as Gd_gdbh,a.jjcp_yjno,rtrim(a.jjcp_cpdh) as 成品编码,rtrim(a.jjcp_cpmc) as 成品名称,a.jjcp_sj,a.jjcp_smb,b.计量单位,
-//                b.Gd_khdh, SUM(d.st_sl) as 实际投料,c.yj_Yjno, c.yj_ls,c.yj_ks,c.质量考核')
-//                    ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_yjno,d.st_rq desc')
-//                    ->group('a.jjcp_gdbh,a.jjcp_yjno')
-//                    ->page($pages)
-//                    ->limit($limit)
-//                    ->select();
-
                 $sql= db('物料_收发记录')
                     ->alias('d')
                     ->where('d.仓库编号', 'Y101')
+                    ->whereOr('d.仓库编号', '101')
                     ->group('d.st_gdbh, d.cpdh')
                     ->field('d.st_gdbh, d.cpdh,d.st_rq, SUM(d.st_sl) as 实际投料,d.仓库编号')
                     ->buildSql();
-
                 $data = db('成品入仓')->alias('a')
                     ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh', 'left')
                     ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh AND a.jjcp_cpdh = c.yj_Yjdh', 'left')
@@ -228,21 +195,12 @@ class OrderSuperLoss extends Api
                     ->page($pages)
                     ->limit($limit)
                     ->select();
-
-//                echo "<pre>";
-//                print_r($data);
-//                echo "<pre>";
-
                 $total = db('成品入仓')->alias('a')
                     ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
                     ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
                     ->where($where)
                     ->count();
             }
-//            echo "<pre>";
-//            print_r($data);
-//            echo "<pre>";
-
             foreach ($data as $key => $value){
                 //查出成品数量及日期
                 $cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$value['Gd_gdbh']}' AND jjcp_yjno = '{$value['jjcp_yjno']}' GROUP BY jjcp_gdbh,jjcp_yjno";
@@ -255,12 +213,6 @@ class OrderSuperLoss extends Api
                         UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$value['Gd_gdbh']}' AND sczl_yjno = '{$value['jjcp_yjno']}') AS combined_result";
                 $gxh_arr = Db::query($gxh_sql);
                 $gxh_values = array_column($gxh_arr, 'sczl_gxh');
-//                $gy_data =db('工单_工艺资料')
-//                    ->where('Gy0_gdbh',$value['Gd_gdbh'])
-//                    ->where('Gy0_yjno',$value['jjcp_yjno'])
-//                    ->where('Gy0_gxh','in',$gxh_values)
-//                    ->field('Gy0_gxmc,Gy0_计划接货数,Gy0_计划损耗')
-//                    ->select();
                 $gy_data =db('工单_工艺资料')
                     ->alias('a')
                     ->field([
@@ -287,23 +239,17 @@ class OrderSuperLoss extends Api
                     }
                     $arr[$k] = floor($rate * 10000) /10000;
                     $plan_loss[$k] = $v['Gy0_计划损耗'];
-
-//                    if (strpos($v['Gy0_gxmc'],'机检') !== false){
-//                        $machine_plan_loss = $v['Gy0_计划损耗'];
-//                    }
                 }
-
                 if ((int)$value['yj_ls'] > 0){
                     $value['实际投料'] = number_format(((int)$value['实际投料']/10000)*$value['yj_ls']*$value['yj_ks'],4);
                 }else{
                     $value['实际投料'] = number_format($value['实际投料']/10000,4);
                 }
                 $data[$key]['实际投料'] = $value['实际投料'];
-
                 if ($value['实际投料'] >0 ){
                     $target_rate =  (1-array_sum($arr))*100;
                     $data[$key]['target_rate'] =$target_rate.'%'; //目标合格率
-                    $real_rate = $cp_data[0]['cp_sl'] / ($value['实际投料'] * 10000) *100;
+                    $real_rate = $cp_data[0]['cp_sl'] / ((float)str_replace(',', '', $value['实际投料']) * 10000) *100;
                     $data[$key]['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
                 }else{
                     $data[$key]['target_rate'] = ''; //目标合格率
@@ -319,7 +265,7 @@ class OrderSuperLoss extends Api
                     $wasteTotal = 0;
                 }
                 $data[$key]['废品合计'] = $wasteTotal + $data[$key]['zcfp'];//废品合计
-                $data[$key]['工单无形损'] = (int)($value['实际投料'] *10000) - $cp_data[0]['cp_sl'] - $data[$key]['废品合计'];//工单无形损
+                $data[$key]['工单无形损'] = (int)((float)str_replace(',', '', $value['实际投料']) *10000) - $cp_data[0]['cp_sl'] - $data[$key]['废品合计'];//工单无形损
                 $out_sql = "SELECT 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_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, 
                         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,
@@ -438,7 +384,7 @@ class OrderSuperLoss extends Api
      * 获取工单超节损工艺
      * @ApiMethod GET
      * @params string order
-    */
+     */
     public function getOrderSuperLossGy(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -477,7 +423,7 @@ class OrderSuperLoss extends Api
      * @ApiMethod GET
      * @params string order
      * 节损奖 小盒0.02 大盒0.09
-    */
+     */
     public function getOrderSuperLossCount(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -495,10 +441,13 @@ class OrderSuperLoss extends Api
             ->where('a.Gd_Gdbh',$order)
             ->where('a.行号',$params['yjno'])
             ->where('c.yj_Yjno',$params['yjno'])
-            ->where('b.仓库编号','Y101')
+            ->where(function($query) {
+                $query->where('b.仓库编号', '101')
+                    ->whereOr('b.仓库编号', 'Y101');})
             ->where('c.质量考核',null)
             ->field($field)
             ->find();
+
         if (empty($data)){
             $this->error('该工单不参与考核');
         }
@@ -508,7 +457,12 @@ class OrderSuperLoss extends Api
         if ($data['ks'] == 0){
             $data['ks'] === 1;
         }
-        $data['实际投料'] = number_format($data['投料']*$data['ls']*$data['ks']/10000,4);
+//        $data['实际投料'] = number_format($data['投料']*$data['ls']*$data['ks']/10000,4);
+        $data['实际投料'] = number_format($data['投料'] * $data['ls'] * $data['ks'] / 10000, 4, '.', '');
+        if($data['实际投料'] == 0){
+            $this->error('投料数据为 0');
+            return;
+        }
         //查出成品数量及日期
         $cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$order}' AND jjcp_yjno = '{$params['yjno']}' GROUP BY jjcp_gdbh,jjcp_yjno";
         $cp_data = Db::query($cp_sql);
@@ -557,7 +511,7 @@ class OrderSuperLoss extends Api
         }
         $target_rate =  (1-array_sum($arr))*100;
         $data['target_rate'] =$target_rate.'%'; //目标合格率
-        $real_rate = $cp_data[0]['cp_sl'] / ($data['实际投料'] * 10000) *100;
+        $real_rate = $cp_data[0]['cp_sl'] / ((float)$data['实际投料'] * 10000) *100;
         $data['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
         //制程废品
         $zzfp_data =db('设备_产量计酬')->where('sczl_gdbh',$order)->where('sczl_yjno',$params['yjno'])->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
@@ -573,7 +527,7 @@ class OrderSuperLoss extends Api
         //废品合计
         $waste_total = $data['zcfp'] + $wasteTotal;
         //工单无形损
-        $data['intangible_loss'] = (int)($data['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $waste_total);
+        $data['intangible_loss'] = (int)((float)$data['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $waste_total);
         $out_sql = "SELECT 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_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, 
                         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,
@@ -610,8 +564,8 @@ class OrderSuperLoss extends Api
                 }
 //                if (!empty($entry[$bhKey])) {
 //                    if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
-                        $quality[$m]= $entry[$slKey];
-                        $m++;
+                $quality[$m]= $entry[$slKey];
+                $m++;
 //                    }
 //                }
 
@@ -623,6 +577,10 @@ class OrderSuperLoss extends Api
         $data['工单质检废'] =  array_sum($quality);//质检废
 //        $data['分摊废'] = '';//分摊废
         $plan_total =db('工单_工艺资料')->where(['Gy0_gdbh' => $order,'Gy0_yjno' => $params['yjno'], 'Gy0_gxh' => ['in', $gxh_values]])->value('SUM(Gy0_计划损耗 * Gy0_ls * Gy0_ks)');
+        if($plan_total == 0){
+            $this->error('计划损耗数据为 0');
+            return;
+        }
         //单据列表最后统计
         $total = [];
         $total['plan_loss'] = 0;
@@ -862,7 +820,7 @@ class OrderSuperLoss extends Api
      * 获取工单工艺
      * @ApiMethod GET
      * @params string order
-    */
+     */
     public function getOrderGy(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -880,7 +838,7 @@ class OrderSuperLoss extends Api
      * 更新工单工艺
      * @ApiMethod POST
      * @params array data
-    */
+     */
     public function updateOrderGy(){
         if (Request::instance()->isPost() == false) {
             $this->error('非法请求');
@@ -911,7 +869,7 @@ class OrderSuperLoss extends Api
      * 获取工单印件考核资料
      * @ApiMethod GET
      * @params string order
-    */
+     */
     public function getOrderYj(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -933,7 +891,7 @@ class OrderSuperLoss extends Api
      * 更新工单印件考核资料
      * @ApiMethod POST
      * @params array data
-    */
+     */
     public function updateOrderYj(){
         if ($this->request->isGet() === false){
             $this->error('请求错误');
@@ -968,7 +926,7 @@ class OrderSuperLoss extends Api
      * @ApiMethod GET
      * @params string year
      * @params string month
-    */
+     */
     public function getOrderFeedList(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -988,7 +946,9 @@ class OrderSuperLoss extends Api
 //            ->where('a.投料确认','like','%'.$search.'%')
             ->where('a.Gd_gdbh',$params['workorder'])
             ->where('c.yj_Yjno',$params['yjno'])
-            ->where('d.仓库编号','Y101')
+            ->where(function($query) {
+                $query->where('d.仓库编号', '101')
+                    ->whereOr('d.仓库编号', 'Y101');})
             ->field($field)
             ->group('a.Gd_gdbh,d.Uniqid')
             ->order('b.BOM_投料单位,a.UniqId asc')
@@ -1021,7 +981,7 @@ class OrderSuperLoss extends Api
      * @ApiMethod POST
      * @params int UniqId
      * @params string number
-    */
+     */
     public function updateOrderFeed(){
         if (Request::instance()->isPost() == false) {
             $this->error('非法请求');
@@ -1050,7 +1010,9 @@ class OrderSuperLoss extends Api
             ->join('工单_印件资料 b','a.st_gdbh = b.Yj_Gdbh AND a.cpdh = b.yj_yjdh')
             ->where('a.st_gdbh',$list['st_gdbh'])
             ->where('a.cpdh',$list['cpdh'])
-            ->where('a.仓库编号','Y101')
+            ->where(function($query) {
+                $query->where('a.仓库编号', '101')
+                    ->whereOr('a.仓库编号', 'Y101');})
             ->find();
         $number = $total_num['投料数量']/10000*$total_num['yj_ls']*$total_num['yj_ks'];
         $res_sql = db('工单_基本资料')->where('Gd_gdbh',$list['st_gdbh'])->where('Gd_cpdh',$list['cpdh'])->fetchSql(true)->setField('实际投料',$number);
@@ -1074,7 +1036,7 @@ class OrderSuperLoss extends Api
      * 工单工序产量统计
      * @ApiMethod GET
      * @params string order
-    */
+     */
     public function getOrderProcessCount(){
         if (Request::instance()->isGet() == false) {
             $this->error('非法请求');
@@ -1183,8 +1145,6 @@ class OrderSuperLoss extends Api
         }
         $date = $params['date'];
         $workOrderData = \db('成品入仓')
-//            ->where('jjcp_gdbh','Y2406020')
-//            ->where('jjcp_yjno','4')
             ->where('jjcp_sj','like',$date.'%')
             ->group('jjcp_gdbh,jjcp_yjno')
             ->order('UniqId desc')
@@ -1207,7 +1167,9 @@ class OrderSuperLoss extends Api
                 ->join('工单_印件资料 c','c.Yj_Gdbh = a.Gd_gdbh AND c.yj_Yjdh = a.Gd_cpdh')
                 ->where('a.Gd_Gdbh',$value['jjcp_gdbh'])
                 ->where('c.yj_Yjno',$value['jjcp_yjno'])
-                ->where('b.仓库编号','Y101')
+                ->where(function($query) {
+                    $query->where('b.仓库编号', '101')
+                        ->whereOr('b.仓库编号', 'Y101');})
                 ->field($field)
                 ->find();
             if ($data[$key]['ls'] == 0){
@@ -1461,6 +1423,7 @@ class OrderSuperLoss extends Api
                 }
             }
         }
+        halt($datanumber);
         $res = [
             '印刷车间' => [
                 'A班'=>[],

+ 1 - 0
application/api/controller/Product.php

@@ -677,6 +677,7 @@ class Product extends Api
      * @ApiMethod GET
      *
     */
+    
     public function getProductYjList(){
         if (Request::instance()->isGet() == false){
             $this->error('非法请求');