liuhairui 1 éve
szülő
commit
a38fe86146

+ 262 - 122
application/api/controller/Manufacture.php

@@ -932,72 +932,142 @@ class Manufacture extends Api
     }
 
     /**
-     * 生产数据菜单显示
-     * @return void
+     * 月度车间报工汇总-菜单显示
      */
-    public function MachineList()
-    {
-        if ($this->request->isGet() === false){
+    public function MachineList(){
+        if ($this->request->isGet() === false) {
             $this->error('请求错误');
         }
-        $date = date('Y-m-d 00:00:00',time()-1888000);
+        $date = date('Y-m-d 00:00:00', time() - 1888000);
+
+        $clwhere['mod_rq'] = null;
         $arr = \db('设备_产量计酬')
             ->field([
                 'DISTINCT(date_format(sczl_rq,"%Y-%m-%d"))' => '时间',
                 'rtrim(sczl_jtbh)' => '机台编号'
             ])
-            ->where('sczl_rq','>',$date)
+            ->where('sczl_rq', '>', $date)
+            ->where($clwhere)
             ->order('sczl_rq desc')
             ->select();
+        $list = ['裁剪','车缝', '手工', '大烫', '总检', '包装'];
+
         $MachineList = \db('设备_基本资料')
-            ->where('生产工序','in',['车缝','后道','总检','大烫','包装'])
+            ->where('生产工序', 'in', $list)
             ->select();
-        $list = ['车缝','后道','总检','大烫','包装'];
-        $data =[];
-        foreach ($list as $m=>$n){
+
+        $data = [];
+
+        foreach ($list as $m => $n) {
             $data[$n] = [];
-            foreach ($MachineList as $key=>$value){
-                if ($n === $value['生产工序']){
-                    $data[$n][$value['设备编号'].'--'.$value['设备编组']] = [];
-                    foreach ($arr as $k=>$v){
-                        if ($value['设备编号'] === $v['机台编号']){
-                            array_push($data[$n][$value['设备编号'].'--'.$value['设备编组']],$v['时间']);
+            foreach ($MachineList as $key => $value) {
+                if ($n === $value['生产工序']) {
+                    $data[$n][$value['设备编号'] . '--' . $value['设备编组']] = [];
+                    foreach ($arr as $k => $v) {
+                        if ($value['设备编号'] === $v['机台编号']) {
+                            array_push($data[$n][$value['设备编号'] . '--' . $value['设备编组']], $v['时间']);
                         }
                     }
                 }
             }
         }
-        $this->success('成功',$data);
+
+        // 将数据转换为所需格式,保留月份和日期
+        $formattedData = [];
+        foreach ($data as $process => $machines) {
+            foreach ($machines as $machine => $dates) {
+                foreach ($dates as $date) {
+                    $yearMonth = substr($date, 0, 7); // 年份
+                    $monthDay = substr($date, 5, 5); // 月份和日期,如 "10-28"
+
+                    // 初始化年份、工序和机器信息
+                    if (!isset($formattedData[$yearMonth])) {
+                        $formattedData[$yearMonth] = [];
+                    }
+                    if (!isset($formattedData[$yearMonth][$process])) {
+                        $formattedData[$yearMonth][$process] = [];
+                    }
+                    if (!isset($formattedData[$yearMonth][$process][$machine])) {
+                        $formattedData[$yearMonth][$process][$machine] = [];
+                    }
+
+                    // 将月份和日期加入到对应机器的数组中
+                    if (!in_array($monthDay, $formattedData[$yearMonth][$process][$machine])) {
+                        $formattedData[$yearMonth][$process][$machine][] = $monthDay;
+                    }
+                }
+            }
+        }
+        $this->success('成功', $formattedData);
     }
 
+
+
     /**
-     * 班组生产数据
-     * @return void
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * 月度车间报工汇总-列表数据
      */
     public function MachineDetail()
     {
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
+
         $param = $this->request->param();
         if (empty($param)){
             $this->error('参数错误');
         }
-        if (isset($param['date'])){
-            $where['a.sczl_rq'] = $param['date'];
+
+        $where = [];
+
+
+        if (isset($param['date'])) {
+            // 检查 `date` 的格式是否为 "YYYY-MM" 或 "MM-DD"
+            if (preg_match('/^\d{4}-\d{2}$/', $param['date'])) {
+                // 如果格式为 "YYYY-MM",则查询当月数据
+                $where['a.sczl_rq'] = ['like', "{$param['date']}%"];
+            } elseif (preg_match('/^\d{2}-\d{2}$/', $param['date'])) {
+                // 如果格式为 "MM-DD",则查询指定的月份和日期
+                $monthDay = $param['date'];
+                $where['a.sczl_rq'] = ['like', "%-$monthDay%"];
+            }
         }
+
+        // 判断是否传入订单编号参数
+        if(!empty($param['order'])){
+            $where['b.订单编号'] = $param['order'];
+        }
+
         $where['a.sczl_jtbh'] = $param['machine'];
-        $list = \db('设备_产量计酬')
-            ->alias('a')
-            ->join('工单_印件资料 b','b.订单编号 = a.订单编号 AND a.子订单编号 = a.子订单编号')
-            ->field('b.订单编号,b.子订单编号,b.款号,b.颜色,b.船样,a.尺码,b.zdtotal as 制单数,a.数量 as 已完成,a.sys_rq as 上报时间')
+        $list = \db('设备_产量计酬')->alias('a')
+            ->join('工单_印件资料 b', 'b.订单编号 = a.订单编号 AND a.子订单编号 = a.子订单编号')
+            ->join('工单_基本资料 j', 'b.订单编号 = j.订单编号', 'LEFT')
+            ->field('
+                b.订单编号, b.子订单编号, b.款号, b.颜色, b.船样, a.尺码, b.zdtotal as 制单数,b.颜色备注,
+                a.数量 as 已完成, a.sys_rq as 上报时间,a.UniqId,
+                j.客户编号,j.生产款号,j.款式
+                ')
             ->where($where)
+            ->where('a.mod_rq',null)
+            ->order('a.sczl_rq desc')
             ->group('a.UniqId')
             ->select();
-        $this->success('成功',$list);
+
+        // 提取所有的尺码,并去重
+        $sizeList = array_values(array_unique(array_column($list, '尺码')));
+
+        // 动态将尺码的数量添加到每个订单中,并替换已完成字段
+        foreach ($list as &$item) {
+            $size = $item['尺码'];
+            $item[$size] = $item['已完成']; // 动态添加尺码字段,值为数量
+            unset($item['已完成']); // 移除原来的已完成字段
+        }
+
+        // 返回结果
+        $this->success('请求成功', [
+            'table' => $list,
+            'length' => count($list),
+            'headers' => $sizeList // 返回所有的尺码作为表头
+        ]);
     }
 
     /**
@@ -1058,125 +1128,185 @@ class Manufacture extends Api
     }
 
     /**
-     * 月度工序产量列表
-     * @return void
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * 月度客户订单汇总
      */
-    public function OrderYieldList()
-    {
-        // 判断是否是GET请求
-        if ($this->request->isGet() === false){
-            $this->error('请求错误');
-        }
-
-        // 获取请求参数
+    public function OrderYieldList(){
+        // 获取前端传来的参数
         $param = $this->request->param();
-
         // 处理搜索条件
         if (isset($param['search'])){
-            $where['a.订单编号'] = ['like','%'.$param['search'].'%'];
+            $where['j.订单编号'] = ['like','%'.$param['search'].'%'];
         }
         if (isset($param['client'])){
-            $where['b.客户编号'] = $param['client'];
+            $where['j.客户编号'] = $param['client'];
+        }
+        if (isset($param['date'])) {
+            $year = substr($param['date'], 0, 4);
+            $month = substr($param['date'], 4, 2);
+            $where['j.Sys_rq'] = ['like', "$year-$month%"];
         }
-
         // 只查询生产中的工单
-        $where['b.gd_statu'] = '2-生产中';
-
-        // 查询第一个表,获取产量信息,添加a.sys_rq字段
-        $list = \db('设备_产量计酬')
-            ->alias('a')
-            ->join('工单_基本资料 b', 'a.订单编号 = b.订单编号')
-            ->join('工单_印件资料 c', 'a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号')
-            ->field('c.订单编号, c.子订单编号, c.款号, c.颜色, c.zdtotal as 制单总数, c.sctotal as 裁切总数, c.ck_rq as 出库日期, a.sys_rq, 
-                 SUM(a.数量) as 产量, a.工序名称')
+        $where['j.gd_statu'] = '2-生产中';
+        $where['j.Mod_rq'] = null;
+        // 查询工单基本资料,获取订单编号和其他基本信息
+        $orderList = \db('工单_基本资料')
+            ->alias('j')
+            ->join('工单_印件资料 y', 'j.订单编号 = y.订单编号')
+            ->field('y.订单编号, j.落货日期, j.生产款号, j.款式, SUM(y.sctotal) as 裁剪总数, SUM(y.zdtotal) as 制单总数')
+            ->group('y.订单编号')  // 去重订单编号
             ->where($where)
-            ->whereNotNull('c.sc_rq')  // 过滤出生产日期不为空的数据
-            ->group('a.订单编号, a.工序名称')
-            ->order('c.Uniqid')
             ->select();
-
-        // 查询第二个表,获取订单的基本信息
-        $orderList = \db('工单_印件资料')
+        $orderIds = array_column($orderList, '订单编号');
+        // 通过订单编号关联设备_产量计酬表,获取工序名称和数量,并进行分组和汇总
+        $processList = \db('设备_产量计酬')
             ->alias('a')
-            ->join('工单_基本资料 b', 'a.订单编号 = b.订单编号')
-            ->field('a.订单编号, a.子订单编号, a.款号, a.颜色, a.zdtotal as 制单总数, a.sctotal as 裁切总数, a.ck_rq as 出库日期')
-            ->where($where)
-            ->whereNotNull('a.sc_rq')
-            ->group('a.子订单编号')
-            ->order('a.Uniqid')
+            ->join('工单_基本资料 j', 'a.订单编号 = j.订单编号')
+            ->whereIn('a.订单编号', $orderIds)  // 只查询符合条件的订单编号
+            ->field('a.订单编号, a.工序名称, SUM(a.数量) as 总数量')
+            ->group('a.订单编号, a.工序名称')  // 按订单编号和工序名称分组
             ->select();
 
+        // 合并两个结果
         $data = [];
-
-        // 合并两个查询结果
-        foreach ($orderList as $key => $value){
-            $data[$key] = $value; // 先将订单基本信息放入$data
-            foreach ($list as $k => $v){
-                if ($value['子订单编号'] === $v['子订单编号']) {
-                    // 根据工序名称,将对应的产量数据加入到订单信息中
-                    if (!isset($data[$key][$v['工序名称']])){
-                        $data[$key][$v['工序名称']] = $v['产量'];
-                    }
-                    // 添加sys_rq到结果
-                    $data[$key]['sys_rq'] = $v['sys_rq'];
+        foreach ($orderList as $key => $order) {
+            // 去掉落货日期的时间部分,只保留日期
+            $orderDate = substr($order['落货日期'], 0, 10);  // 提取前10位
+            //放入结果
+            $data[$key] = [
+                '订单编号' => $order['订单编号'],
+                '落货日期' => $order['落货日期'],
+                '生产款号' => $order['生产款号'],
+                '款式' => $order['款式'],
+                '裁剪总数' => $order['裁剪总数'],
+                '制单总数' => $order['制单总数'],
+            ];
+            // 找到该订单编号对应的工序名称和数量
+            foreach ($processList as $process) {
+                if ($process['订单编号'] === $order['订单编号']) {
+                    // 将工序名称和数量加入到结果中
+                    $data[$key][$process['工序名称']] = $process['总数量'];
                 }
             }
         }
-
-        // 返回成功的结果,包含合并后的数据
+        // 返回最终结果
         $this->success('成功', $data);
-    }
+        die;
 
-    /**
-     * 月度工序产量左侧菜单
-     * @return void
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-//    public function dateList()
-//    {
+//        // 判断是否是GET请求
 //        if ($this->request->isGet() === false){
 //            $this->error('请求错误');
 //        }
-//        // 查询并按月份统计
-//        $result = Db::name('工单_基本资料')
-//            ->field("DATE_FORMAT(Sys_rq, '%Y-%m') as month")
-//            ->group("DATE_FORMAT(Sys_rq, '%Y-%m')")
+//
+//        // 获取请求参数
+//        $param = $this->request->param();
+//
+//        // 处理搜索条件
+//        if (isset($param['search'])){
+//            $where['a.订单编号'] = ['like','%'.$param['search'].'%'];
+//        }
+//        if (isset($param['client'])){
+//            $where['b.客户编号'] = $param['client'];
+//        }
+//        if (isset($param['date'])) {
+//            $year = substr($param['date'], 0, 4);
+//            $month = substr($param['date'], 4, 2);
+//            $where['b.Sys_rq'] = ['like', "$year-$month%"];
+//        }
+//        // 只查询生产中的工单
+//        $where['b.gd_statu'] = '2-生产中';
+//        $where['b.Mod_rq'] = null;
+//
+//        // 查询第一个表,获取产量信息,添加a.sys_rq字段
+//        $list = \db('设备_产量计酬')->alias('a')
+//            ->join('工单_基本资料 b', 'a.订单编号 = b.订单编号')
+//            ->join('工单_印件资料 c', 'a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号')
+//            ->field('b.订单编号, SUM(c.zdtotal) as 制单总数, SUM(c.sctotal) as 裁剪总数, SUM(a.数量) as 产量, a.工序名称, b.落货日期,
+//                c.颜色, a.sys_rq')
+//            ->where($where)
+//            ->whereNotNull('c.sc_rq')
+//            ->group('a.子订单编号, a.工序名称, c.颜色')
+//            ->order('c.Uniqid')
 //            ->select();
-//        $list = $this->array_flatten($result);
-//        $this->success('成功',$list);
-//    }
 //
-//    function array_flatten($array) {
-//        $result = [];
-//        foreach ($array as $value) {
-//            if (is_array($value)) {
-//                $result = array_merge($result, $this->array_flatten($value));
-//            } else {
-//                $result[] = $value;
+//
+//        // 查询第二个表,获取订单的基本信息
+//        $orderList = \db('工单_印件资料')
+//            ->alias('a')
+//            ->join('工单_基本资料 b', 'a.订单编号 = b.订单编号')
+//            ->field('a.订单编号, b.生产款号, SUM(a.zdtotal) as 制单总数, SUM(a.sctotal) as 裁剪总数, b.落货日期,
+//                  a.颜色, a.ck_rq as 出库日期')
+//            ->where($where)
+//            ->whereNotNull('a.sc_rq')
+//            ->group('a.子订单编号, a.颜色')
+//            ->order('a.Uniqid')
+//            ->select();
+//
+//        $data = [];
+//
+//        // 合并两个查询结果
+//        foreach ($orderList as $key => $value){
+//            $data[$key] = $value; // 先将订单基本信息放入$data
+//            foreach ($list as $k => $v){
+//                if ($value['订单编号'] === $v['订单编号'] && $value['颜色'] === $v['颜色']) {
+//                    // 根据工序名称,将对应的产量数据加入到订单信息中
+//                    if (!isset($data[$key][$v['工序名称']])){
+//                        $data[$key][$v['工序名称']] = $v['产量'];
+//                    }
+//                    // 添加sys_rq到结果
+//                    $data[$key]['sys_rq'] = $v['sys_rq'];
+//                }
 //            }
 //        }
-//        return $result;
-//    }
+//
+//        // 返回成功的结果,包含合并后的数据
+//        $this->success('成功', $data);
+    }
+
+    /**
+     * 订单状态及样衣批核-左侧菜单
+     */
+    public function dateList()
+    {
+
+    }
 
     /**车缝派单菜单
      * @return void
      */
     public function CfmachineList()
     {
-        if ($this->request->isGet() === false){
+        if ($this->request->isGet() === false) {
             $this->error('请求错误');
         }
-        $list = \db('设备_基本资料')
-            ->where('生产工序','车缝')
-            ->column('设备编号');
-        $this->success('成功',$list);
+        // 查询所有生产工序为"车缝"的设备编号和设备编组
+        $machineList = \db('设备_基本资料')
+            ->where('生产工序', '车缝')
+            ->field('设备编号, 设备编组')
+            ->select();
+        $result = [];
+        foreach ($machineList as $machine) {
+            $machineCode = $machine['设备编号'];
+            $machineGroup = $machine['设备编组'];
+            // 查询该设备编号在 设备_产量计酬 表中的订单编号
+            $orders = \db('设备_产量计酬')
+                ->where('sczl_jtbh', $machineCode)
+                ->where('mod_rq', null)
+                ->column('订单编号');
+
+            // 去重统计订单编号数量
+            $workOrderCount = count(array_unique($orders));
+
+            // 构建返回数据,格式为:设备编号【设备编组 生产中:工单数量】
+            $result[] = $machineCode . '【' . $machineGroup . ' 生产中:' . $workOrderCount . '】';
+        }
+        $yearMonth = date('Ym');
+        $finalResult = [
+            $yearMonth => $result
+        ];
+        $this->success('成功', $finalResult);
     }
 
+
     /**
      * 车缝派单列表
      * @return void
@@ -1186,23 +1316,33 @@ class Manufacture extends Api
      */
     public function CfdataList()
     {
-        if ($this->request->isGet() === false){
+        if ($this->request->isGet() === false) {
             $this->error('请求错误');
         }
+
         $param = $this->request->param();
-        if (empty($param)){
+        if (empty($param)) {
             $this->error('参数错误');
         }
-        $list = \db('工单_排程班次')
-            ->where('班组编号',$param['machine'])
-            ->where('mod_rq',null)
-            ->order('sys_rq desc')
-            ->field('订单编号,子订单编号,班组编号,sys_rq as 创建时间,sys_id as 创建人员,UniqId')
-            ->group('子订单编号')
+
+        // 查询设备产量计酬与工单基本资料的关联数据
+        $list = \db('设备_产量计酬')->alias('c')
+            ->join('工单_基本资料 j', 'c.订单编号 = j.订单编号', 'left')
+            ->where('c.sczl_jtbh', $param['machine'])
+            ->where('j.mod_rq', null)
+            ->field('
+            j.订单编号, j.生产款号, j.款式, j.客户编号, j.订单数量, 
+            LEFT(j.落货日期, 10) as 落货日期,  -- 只保留日期部分
+            j.Sys_rq as 创建时间, j.gd_statu as 工单状态
+        ')
+            ->group('j.订单编号')
             ->select();
-        $this->success('成功',$list);
+
+        // 返回数组结果
+        $this->success('请求成功', ['table' => $list, 'length' => count($list)]);
     }
 
+
     //车缝派单删除
     public function CfdataDel()
     {

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 828 - 104
application/api/controller/WorkOrder.php


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 363 - 197
application/api/controller/WorkOrderSpotCheck.php


+ 116 - 727
application/api/controller/WorkOrderVerification.php

@@ -107,14 +107,10 @@ class WorkOrderVerification extends Api
      */
     public function getList()
     {
-        // 检查是否为 GET 请求
         if(!$this->request->isGet()){
             $this->error('请求方式错误');
         }
-
-        // 获取请求参数
         $param = $this->request->param();
-
         // 判断订单编号是否包含 '-'
         if (strpos($param['order'], '-') !== false) {
             // 如果订单包含 '-',则按子订单编号精确匹配
@@ -123,16 +119,13 @@ class WorkOrderVerification extends Api
             // 如果订单不包含 '-',则按订单编号进行模糊匹配
             $where['订单编号'] = ['like', '%' . $param['order'] . '%'];
         }
-
         // 过滤条件中的 code
         $where['code'] = $param['code'];
-
         // 查询数据库
         $rows = db()->table('设备_报工记录')
             ->where($where)
             ->order('子订单编号 desc')
             ->select();
-
         // 提取 cm1 到 cm10 的数据
         $headers = [];
         if (!empty($rows)) {
@@ -145,855 +138,251 @@ class WorkOrderVerification extends Api
                     }
                 }
             }
-
             // 去重,避免重复值
             $headers = array_unique($headers);
-
-            // 按照数值升序排序
             sort($headers);
         }
-
-
-        // 构建返回的数据结构
         $data = [
             'table'   => $rows,
             'headers' => $headers,
             'total'   => count($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_qczl')->alias('d')
-            ->field('d.*, ')
-            ->join('工单_基本资料 g', 'd.')
-            ->where('d.UniqId',$UniqId)
-            ->select();
-
-
-        $this->success('成功',$rows);
-    }
     /**
      * 生产产量进度月报表(Excel)
-     * @params string UniqId
      */
     public function getOneWorkOrder() {
-        // 确认请求为 GET 请求
         if (!$this->request->isGet()) {
             $this->error('请求方式错误');
         }
 
-        // 获取请求参数
         $param = $this->request->param();
+        $currentMonth = date('Y-m', strtotime($param['riqi']));  // 获取前端传来的日期所在月份,格式为 Y-m
+        $lastMonth = date('Y-m', strtotime($param['riqi'] . ' -1 month'));  // 获取前端日期的上个月,格式为 Y-m
 
-        // 获取当前月份和上个月的月份
-        $currentMonth = date('Y-m', strtotime($param['riqi']));  // 当前月份
-        $previousMonth = date('Y-m', strtotime('-1 month', strtotime($param['riqi'])));  // 上个月
+        // 当前月份的查询条件
+        $where['c.sczl_rq'] = ['like', '%' . $currentMonth . '%'];
 
-        // 查询当前月份的数据
-        $where['上报时间'] = ['like', $currentMonth . '%'];
-        $rows = db()->table('设备_报工记录')
-            ->field('款式,款号,订单编号,组别,客户编号,code as 工序,上报数量,sctotal as 裁剪数,zdtotal as 制单数,scsl1,scsl2,scsl3,scsl4,scsl5,scsl6,scsl7,scsl8,scsl9,scsl10,上报时间')
-            ->where($where)
+        // 查询当前订单的生产总数和整单总数
+        $totals = db()->table('工单_印件资料')->alias('y')
+            ->field('y.订单编号, SUM(y.sctotal) as sctotal, SUM(y.zdtotal) as zdtotal')
+            ->group('y.订单编号')
+            ->order('y.订单编号')
             ->select();
 
-        // 查询上个月的数据
-        $wherePrevious['上报时间'] = ['like', $previousMonth . '%'];
-        $rowsPrevious = db()->table('设备_报工记录')
-            ->field('款式,款号,订单编号,组别,客户编号,sctotal as 裁剪数,zdtotal as 制单数,scsl1,scsl2,scsl3,scsl4,scsl5,scsl6,scsl7,scsl8,scsl9,scsl10,上报时间')
-            ->where($wherePrevious)
+        // 保存当前订单的生产总数和整单总数到一个数组,以便后续关联
+        $totalsMap = [];
+        foreach ($totals as $total) {
+            $totalsMap[$total['订单编号']] = [
+                'sctotal' => $total['sctotal'],
+                'zdtotal' => $total['zdtotal'],
+            ];
+        }
+
+        // 查询上月累计数据
+        $wheres['sczl_rq'] = ['like', '%' . $lastMonth . '%'];
+        $sql = db()->table('设备_产量计酬')
+            ->field('订单编号, SUM(数量) as 上月累计') // 使用SUM函数统计上月累计数量
+            ->where($wheres)
+            ->group('订单编号')
             ->select();
 
-        // 初始化结果数组
-        $result = [];
+        // 将上个月的累计数据保存到一个数组
+        $lastMonthMap = [];
+        foreach ($sql as $lastRow) {
+            $lastMonthMap[$lastRow['订单编号']] = $lastRow['上月累计'];
+        }
+
+        // 查询每天的上报数量,并关联生产总数和整单总数
+        $rows = db()->table('设备_产量计酬')->alias('c')
+            ->join('工单_基本资料 j', 'c.订单编号 = j.订单编号', 'left')
+            ->field('
+            c.订单编号, j.款式, j.生产款号, j.客户编号, 
+            c.sczl_jtbh, c.工序名称 as 工序,c.sczl_bh,
+            c.数量 as 上报数量,  
+            c.sczl_rq as 上报时间  
+        ')
+            ->where($where)
+            ->order('c.sczl_rq desc')
+            ->select();
 
+        // 初始化
+        $result = [];
         // 处理当前月份的数据
         foreach ($rows as $row) {
-            // 使用“款式”、“款号”、“订单编号”、“组别”作为唯一标识
-            $key = $row['款式'] . '_' . $row['款号'] . '_' . $row['订单编号'] . '_' . $row['组别'];
+            $key = $row['款式'] . '_' . $row['生产款号'] . '_' . $row['订单编号'] . '_' . $row['sczl_jtbh'];
 
-            // 如果结果集中不存在该条目,则初始化
+            // 获取当前订单编号的生产总数和整单总数
+            $sctotal = isset($totalsMap[$row['订单编号']]) ? $totalsMap[$row['订单编号']]['sctotal'] : 0;
+            $zdtotal = isset($totalsMap[$row['订单编号']]) ? $totalsMap[$row['订单编号']]['zdtotal'] : 0;
+
+            // 获取上个月的累计数量
+            $lastMonthTotal = isset($lastMonthMap[$row['订单编号']]) ? $lastMonthMap[$row['订单编号']] : 0;
+
+            // 初始化当前订单编号和组别的数据
             if (!isset($result[$key])) {
                 $result[$key] = [
-                    '款式' => $row['款式'],
-                    '款号' => $row['款号'],
                     '订单编号' => $row['订单编号'],
-                    '组别' => $row['组别'],
                     '客户编号' => $row['客户编号'],
+                    '机台号' => $row['sczl_jtbh'],
+                    '款式' => $row['款式'],
+                    '款号' => $row['生产款号'],
                     '工序' => $row['工序'],
-                    '裁剪数' => $row['裁剪数'] ?? 0,
-                    '制单数' => $row['制单数'] ?? 0,
-                    '上报数量' => 0,  // 初始化上报数量累计
+                    '组别' => $row['sczl_bh'],
+                    '制单数' => $zdtotal,
+                    '裁剪数' => $sctotal,
+                    '上个月累计数量' => $lastMonthTotal, // 上个月累计数量
+                    '上报数量' => 0,
                 ];
 
-                // 初始化每数据
+                // 初始化每一天的数据
                 for ($day = 1; $day <= 31; $day++) {
-                    $result[$key][$day . '号'] = 0;
+                    $result[$key][$day] = 0;
                 }
             }
 
-            // 按天累计每日数据
+            // 获取上报的具体日期
             $day = (int)date('d', strtotime($row['上报时间']));
 
-            // 检查 scsl1 到 scsl10 是否都是空
-            $allScslEmpty = true;
-            for ($i = 1; $i <= 10; $i++) {
-                $keyScsl = 'scsl' . $i;
-                if (!empty($row[$keyScsl])) {
-                    $allScslEmpty = false;
-                    break;
-                }
-            }
-
-            // 如果 scsl1-scsl10 全部为空,则累加上报数量
-            if ($allScslEmpty) {
-                $result[$key][$day . '号'] += (int)$row['上报数量'];
-            } else {
-                // 如果有 scsl1-scsl10 的数据,则按原来的逻辑累加
-                for ($i = 1; $i <= 10; $i++) {
-                    $keyScsl = 'scsl' . $i;
-                    $result[$key][$day . '号'] += !empty($row[$keyScsl]) ? (int)$row[$keyScsl] : 0;
-                }
-            }
+            // 按天累加上报数量
+            $result[$key][$day] += (int)$row['上报数量'];
 
-            // 累计上报数量”(非裁剪和制单)
+            // 累计上报数量
             $result[$key]['上报数量'] += (int)$row['上报数量'];
         }
 
         // 计算本月累计数据
         foreach ($result as &$item) {
-            $item['本月累计'] = 0;  // 初始化本月累计
-            $item['上个月累计'] = 0;  // 初始化上个月累计
-
+            $item['本月累计'] = 0;
             // 累计本月每天的数据
             for ($day = 1; $day <= 31; $day++) {
-                $item['本月累计'] += $item[$day . '号'];
-                // 如果当天数据为 0,则显示为空字符串
-                if ($item[$day . '号'] === 0) {
-                    $item[$day . '号'] = '';
+                $item['本月累计'] += $item[$day];
+                if ($item[$day] === 0) {
+                    $item[$day] = '';
                 }
             }
-
-            // 注意:上个月的每日统计数据不需要处理,仅保留本月的累计。
         }
-
-        // 将结果转换为索引数组
+        //排序
+        usort($result, function ($a, $b) {
+            $clientComparison = strcmp($a['客户编号'], $b['客户编号']);
+            if ($clientComparison !== 0) {
+                return $clientComparison;
+            }
+            $groupComparison = strcmp($a['组别'], $b['组别']);
+            if ($groupComparison !== 0) {
+                return $groupComparison;
+            }
+            return strcmp($a['订单编号'], $b['订单编号']);
+        });
         $result = array_values($result);
-
-        // 返回结果
         $this->success('成功', $result);
     }
 
-//    public function getOneWorkOrder() {
-//        // 确认请求为 GET 请求
-//        if (!$this->request->isGet()) {
-//            $this->error('请求方式错误');
-//        }
-//
-//        // 获取请求参数
-//        $param = $this->request->param();
-//
-//        // 获取当前月份和上个月的月份
-//        $currentMonth = date('Y-m', strtotime($param['riqi']));  // 当前月份
-//        $previousMonth = date('Y-m', strtotime('-1 month', strtotime($param['riqi'])));  // 上个月
-//
-//        // 查询当前月份的数据
-//        $where['上报时间'] = ['like', $currentMonth . '%'];
-//        $rows = db()->table('设备_报工记录')
-//            ->field('款式,款号,订单编号,组别,客户编号,code as 工序,上报数量,sctotal as 裁剪数,zdtotal as 制单数,scsl1,scsl2,scsl3,scsl4,scsl5,scsl6,scsl7,scsl8,scsl9,scsl10,上报时间')
-//            ->where($where)
-//            ->select();
-//
-//        // 查询上个月的数据
-//        $wherePrevious['上报时间'] = ['like', $previousMonth . '%'];
-//        $rowsPrevious = db()->table('设备_报工记录')
-//            ->field('款式,款号,订单编号,组别,客户编号,sctotal as 裁剪数,zdtotal as 制单数,scsl1,scsl2,scsl3,scsl4,scsl5,scsl6,scsl7,scsl8,scsl9,scsl10,上报时间')
-//            ->where($wherePrevious)
-//            ->select();
-//
-//        // 初始化结果数组
-//        $result = [];
-//
-//        // 处理当前月份的数据
-//        foreach ($rows as $row) {
-//            // 使用“款式”、“款号”、“订单编号”、“组别”作为唯一标识
-//            $key = $row['款式'] . '_' . $row['款号'] . '_' . $row['订单编号'] . '_' . $row['组别'];
-//
-//            // 如果结果集中已经存在该条目,则进行累加
-//            if (!isset($result[$key])) {
-//                // 初始化一个新的条目
-//                $result[$key] = [
-//                    '款式' => $row['款式'],
-//                    '款号' => $row['款号'],
-//                    '订单编号' => $row['订单编号'],
-//                    '组别' => $row['组别'],
-//                    '客户编号' => $row['客户编号'],
-//                    '工序' => $row['工序'],
-//                    '裁剪数' => $row['裁剪数'] ?? 0,
-//                    '制单数' => $row['制单数'] ?? 0,
-//                ];
-//
-//                // 初始化每日数据
-//                for ($day = 1; $day <= 31; $day++) {
-//                    $result[$key][$day . '号'] = 0;
-//                }
-//            }
-//
-//            // 按天累计数据
-//            $day = (int)date('d', strtotime($row['上报时间']));
-//            for ($i = 1; $i <= 10; $i++) {
-//                $keyScsl = 'scsl' . $i;
-//                $result[$key][$day . '号'] += !empty($row[$keyScsl]) ? (int)$row[$keyScsl] : 0;
-//            }
-//        }
-//
-//
-//
-//        // 计算本月和上个月的累计
-//        foreach ($result as &$item) {
-//            $item['本月累计'] = 0;
-//            $item['上个月累计'] = 0;
-//
-//            // 本月累计
-//            for ($day = 1; $day <= 31; $day++) {
-//                $item['本月累计'] += $item[$day . '号'];
-//                // 如果当日数据为0,则替换为空字符串
-//                if ($item[$day . '号'] === 0) {
-//                    $item[$day . '号'] = '';
-//                }
-//            }
-//
-//            // 上个月累计 (不需要再统计上个月的数据,只保留本月的每日统计)
-//        }
-//
-//        // 将结果转换为索引数组
-//        $result = array_values($result);
-//
-//        $this->success('成功', $result);
-//    }
+
     /**
-     * 获取工单基本信息
-     * @ApiMethod GET
-     * @params string order
+     *
+     */
+    public function getInfo()
+    {
+
+    }
+
+
+    /**
+     *
      */
     public function getOrderInfo(){
 
     }
     /**
-     * 获取印件名称及工序
-     * @ApiMethod GET
-     * @params string order
-     * @params string yj_no
+     *
      */
     public function getYjInfo(){
 
 
     }
     /**
-     * 获取废品分类
-     * @ApiMethod GET
-     * @params string search
+     *
      */
     public function getWastInfo(){
 
     }
     /**
-     *获取工序及责任组长
-     * @ApiMethod GET
-     * @params string type
-     * @params string order
+     *
      */
     public function getGxAndLeader(){
 
     }
     /**
-     * 修改工单核检单
-     * @ApiMethod POST
-     * @params array data
+     *
      */
     public function edit(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        if (!isset($params['UniqId'])){
-            $this->error('参数不能为空');
-        }
-        $id = $params['UniqId'];
-        unset($params['UniqId']);
-        $sql = db('db_qczl')->where('UniqId',$id)->fetchSql(true)->update($params);
-        $res = Db::query($sql);
-        if ($res !== 0){
-            cache('WorkOrderVerification-getTable',null);
-            $this->success('更新成功');
-        }else{
-            $this->error('更新失败');
-        }
+
     }
     /**
-     * 新增工单核检单
-     * @ApiMethod POST
-     * @params array data
+     *
      */
     public function add(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        $UniqId = db('db_qczl')->order('UniqId desc')->value('UniqId');
-        if ($UniqId < 10000000){
-            $UniqId = 10000000;
-        }else{
-            $UniqId = $UniqId + 1;
-        }
-        $params['UniqId'] = $UniqId;
-        $params['sys_rq'] = date('Y-m-d H:i:s');
-        $res = \db('db_qczl')->insert($params);
-        if ($res !== false){
-            cache('WorkOrderVerification-getTable',null);
-            $this->success('新增成功');
-        }else{
-            $this->error('新增失败');
-        }
+
     }
     /**
-     * 工单核检废品分布
-     * @ApiMethod GET
-     * @params string order
+     *
      */
     public function wasteDistribution(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        if (!isset($params['order']) || empty($params['order'])){
-            $this->error('参数错误');
-        }
-        if (!isset($params['yjno']) || empty($params['yjno'])){
-            $this->error('参数错误');
-        }
-        $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,qczl_yjno
-        ';
-//        $data = db('db_qczl')->name('db_qczl')->where('qczl_gdbh',$params['order'])->field($field)->select();
-        $data = db('db_qczl')->name('db_qczl')
-            ->where('qczl_gdbh',$params['order'])
-            ->where('qczl_yjno', $params['yjno'])
-            ->field($field)->select();
-        if (empty($data)){
-            $this->error('暂无废品数据');
-        }
-        // 用于存储废品类别和对应废品数量的数组
-        $categories = array();
-        // 循环遍历原始数组
-        foreach ($data as $item) {
-            // 提取废品类别和对应废品数量
-            foreach ($item as $key => $value) {
-                if (strpos($key, "fp_lb") === 0) {
-                    $categoryKey = $key;
-                    $quantityKey = str_replace("fp_lb", "fp_sl", $key);
-                    $quantityValue = $item[$quantityKey];
-
-                    if (!isset($categories[$value])) {
-                        $categories[$value] = 0;
-                    }
 
-                    $categories[$value] += (int)$quantityValue;
-                }
-            }
-        }
-        ksort($categories);
-        $wasteTotal = db('db_qczl')->where('qczl_gdbh',$params['order'])->sum('qczl_fp');
-        if (empty($wasteTotal)){
-            $wasteTotal = 0;
-        }
-        $where['a.Gd_gdbh'] = $params['order'];
-        $where['a.行号'] = 1;
-        $gdInfo = db('工单_基本资料')->alias('a')
-            ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh','left')
-            ->where($where)->field('a.Gd_gdbh,a.实际投料,b.yj_Yjno,b.yj_yjmc')->find();
-        $gdInfo['yj_Yjno'] = $gdInfo['yj_Yjno'] > 10 ? $gdInfo['yj_Yjno']:'0'.$gdInfo['yj_Yjno'];
-        $gdInfo['实际投料'] = (int)($gdInfo['实际投料'] * 10000);
-        $gdInfo['wasteTotal'] = $wasteTotal;
-        $finishNum = db('成品入仓')->where('jjcp_gdbh',$params['order'])->sum('jjcp_sl');
-        $gdInfo['passRate'] = '';
-        if (!empty($finishNum)){
-            $gdInfo['passRate'] = number_format((int)$finishNum/$gdInfo['实际投料']*100,2).'%';
-        }
-        //左侧废品数据
-        $wasteData = array();
-        $i = 0;
-        foreach ($categories as $key=>$value){
-            if ($value != 0){
-                $wasteData[$i]['type'] = $key;
-                $wasteData[$i]['num'] = $value;
-                $wasteData[$i]['lossesRate'] = number_format($value/$gdInfo['实际投料']*100,4).'%';
-                $wasteData[$i]['wasteRate'] = number_format($value/$wasteTotal*100,2).'%';
-                $i++;
-            }
-        }
-        // 按首字母相同的键将值相加
-        $newArray = array();
-        foreach ($categories as $key => $value) {
-            $firstLetter = strtoupper(substr($key, 0, 1)); // 获取首字母并转换为大写
-
-            if (!isset($newArray[$firstLetter])) {
-                $newArray[$firstLetter] = 0;
-            }
-
-            $newArray[$firstLetter] += $value;
-        }
-        // 去掉值为零的项
-        $newArray = array_filter($newArray, function($value) {
-            return $value !== 0;
-        });
-        //右侧废品数据
-        $rightData = array();
-        $i = 0;
-        $name = array();
-        foreach ($newArray as $key=>$value){
-            $item = db('erp_常用字典')->where('名称','like','%'.$key.'%')->value('名称');
-            $item = explode('_',substr($item,0,-1));
-            $rightData[$i]['type'] = $item[1];
-            $rightData[$i]['rate'] = number_format($value/$wasteTotal*100,0).'%';
-            $name[$i] = $item[1];
-            $i++;
-        }
-        $gdInfo['wasteData'] = $wasteData;
-        $gdInfo['rightData'] = $rightData;
-        $gdInfo['rightTitle'] = $name;
-        $this->success('请求成功',$gdInfo);
     }
     /**
-     * 获取工单工序状态
-     * @ApiMethod GET
-     * @params string order
-     * 计划产量计算方式:上个工序计划产量-(基础损耗+损耗率*上个工序计划产量)*损耗系数*计损色数)
-     * lastNum - (Gy0_Rate0 + Gy0_Rate1 * lastNum )* 损耗系数(Gy0_Rate3) * Gy0_Ms
+     *
      */
     public function getOrderDate(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        if (!isset($params['order']) || empty($params['order'])){
-            $this->error('参数错误');
-        }
-        $where['a.Gy0_gdbh'] = $params['order'];
-        $where['a.Gy0_sbbh'] = array('neq',' ');
-        $productNum = db('工单_基本资料')->where('Gd_gdbh',$params['order'])->value('计划投料');
-        $gyData = db('工单_工艺资料')->alias('a')
-            ->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,
-            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'] = rtrim($process['Gy0_sbbh']);
-            $res[$key]['PD_WG'] = $process['PD_WG'];
-            $res[$key]['finish'] = empty($process['cl']) ? 0: (int)$process['cl'];
-            // 计算工序计划产量
-            if ($process["Gy0_gxh"] == "1") {
-                // 第一道工序直接使用初始计划产量
-                $Num = $lastNum;
-            } else {
-                $Gy0_Ms = $gyData[$key-1]['Gy0_Ms'];
-                $Gy0_Rate0 = $gyData[$key-1]['Gy0_Rate0'];
-                $Gy0_Rate1 = $gyData[$key-1]['Gy0_Rate1'];
-                $Gy0_Rate3 = $gyData[$key-1]['Gy0_Rate3'];
-                // 大于第一道工序,使用上一道工序的计划产量
-                // 根据公式计算工序计划产量
-                if ($Gy0_Ms != "0.00") {
-                    $Num = $lastNum - ($Gy0_Rate0 + $Gy0_Rate1 * $lastNum) * $Gy0_Rate3 * $Gy0_Ms;
-                } else {
-                    $Num = $lastNum - ($Gy0_Rate0 + $Gy0_Rate1 * $lastNum) * $Gy0_Rate3;
-                }
-            }
-            if (trim($process['Gy0_SITE']) == '检验车间'){
-                $res[$key]['plan'] = (int)$process['Gy0_计划接货数'];
-            }else{
-                $res[$key]['plan'] = (int)round($Num);
-            }
-            $finish_rate = $res[$key]['finish']/$res[$key]['plan'];
-            $res[$key]['finish_rate'] = '';
-            if ($finish_rate != 0){
-                $res[$key]['finish_rate'] = number_format($finish_rate*100,2).'%';
-            }
 
-            // 更新 $lastNum 为当前工序的计划产量
-            $lastNum = $Num;
-        }
-        $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('工单_工艺资料')->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('参数错误');
-        }
-        if (!isset($params['yjno']) || empty($params['yjno'])){
-            $this->error('参数错误');
-        }
-        $where['Gd_gdbh'] = $params['order'];
-        $where['行号'] = 1;
-        //工单基本资料
-        $info = db('工单_基本资料')->where($where)->field('rtrim(成品代号)  as code,rtrim(成品名称) as name')->find();
-        //工艺资料
-        $option['Gy0_gdbh'] = $params['order'];
-        $option['Gy0_yjno'] = $params['yjno'];
-        $gyInfo = db('工单_工艺资料')
-            ->where($option)
-            ->where(function ($query) {
-                $query->where('Gy0_sbbh', '<>', '')
-                    ->whereOr('Gy0_gxmc', '核检')
-                    ->whereOr('Gy0_gxmc', '成品防护');
-            })
-            ->field('Gy0_yjno,Gy0_gxh,rtrim(Gy0_gxmc) as Gy0_gxmc')
-            ->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['yjno']) || empty($params['yjno'])){
-            $this->error('参数错误');
-        }
-        if (!isset($params['gxNo']) || empty($params['gxNo'])){
-            $this->error('参数错误');
-        }
-        $total = db('设备_产量计酬')->where('sczl_gdbh',$params['order'])->where('sczl_gdbh',$params['yjno'])->order('sczl_num')->column('distinct(sczl_num)');
-        $where['sczl_gxh'] = (int)$params['gxNo'];
-        $where['sczl_gdbh'] = $params['order'];
-        $where['sczl_yjno'] = $params['yjno'];
-        //机器设备数据
-        $process = db('设备_产量计酬')->where($where)->order('sczl_num')->column('distinct(sczl_num)');
-        //手工数据
-        $option['qczl_gdbh'] = $params['order'];
-        $option['qczl_gxh'] = (int)$params['gxNo'];
-        $option['qczl_yjno'] = $params['yjno'];
-        $handProcess = db('db_qczl')->where($option)->field('qczl_num,qczl_NumDesc1,qczl_NumDesc2,qczl_NumDesc3,qczl_NumDesc4,qczl_NumDesc5,qczl_NumDesc6,qczl_NumDesc7,qczl_NumDesc8')->select();
-        // 提取数据
-        $result = array();
-        foreach ($handProcess as $subArray) {
-            $qczl_num = $subArray["qczl_num"];
-            $result[] = $qczl_num;
-            // 提取以qczl_NumDesc开头的键对应的值
-            for ($i = 1; $i <= 8; $i++) {
-                $key = "qczl_NumDesc" . $i;
-                if ($subArray[$key] != 0){
-                    $result[] = $subArray[$key];
-                }
-            }
-        }
-        // 去重
-        $result = array_unique($result);
-        // 对结果进行排序
-        sort($result);
-        $res['total_process'] = $total;
-        $res['process'] = $process;
-        if (empty($process)){
-            $res['process'] = $result;
-        }
-        $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['end_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
-        ';
-        $resultArray = array();
-        $key = 'getDaysWast'.$params['start_date'].'/'.$params['end_date'];
-        $is_have_cache = Cache::has($key);
-        if ($is_have_cache === false){
-            $data = db('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('人事_基本资料')->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++;
-                        }
-                    }
-                }
-            }
-            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;
-            });
-            Cache::set($key,$resultArray,86400);
-        }else{
-            $resultArray = Cache::get($key);
-        }
-
-        $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('参数错误');
-        }
+
 
     }
     /**
-     * 工单质检废品统计
-     * @ApiMethod GET
-     * @params string order
+     *
      */
     public function getOrderWasteTotal(){
-        if (Request::instance()->isGet() == false) {
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        if (!isset($params['order']) || empty($params['order'])) {
-            $this->error('参数错误');
-        }
-        $field = '
-        rtrim(a.fp_lb1) as fp_lb1,rtrim(a.fp_lb2) as fp_lb2,rtrim(a.fp_lb3) as fp_lb3,rtrim(a.fp_lb4) as fp_lb4,rtrim(a.fp_lb5) as fp_lb5,rtrim(a.fp_lb6) as fp_lb6,rtrim(a.fp_lb7) as fp_lb7,
-        rtrim(a.fp_lb8) as fp_lb8,rtrim(a.fp_lb9) as fp_lb9,rtrim(a.fp_lb10) as fp_lb10,rtrim(a.fp_lb11) as fp_lb11,rtrim(a.fp_lb12) as fp_lb12,rtrim(a.fp_lb13) as fp_lb13,
-        a.fp_sl1,a.fp_sl2,a.fp_sl3,a.fp_sl4,a.fp_sl5,a.fp_sl6,a.fp_sl7,a.fp_sl8,a.fp_sl9,a.fp_sl10,a.fp_sl11,a.fp_sl12,a.fp_sl13,
-        a.fp_bh1,a.fp_bh2,a.fp_bh3,a.fp_bh4,a.fp_bh5,a.fp_bh6,a.fp_bh7,a.fp_bh8,a.fp_bh9,a.fp_bh10,a.fp_bh11,a.fp_bh12,a.fp_bh13,
-        rtrim(a.fp_gxmc1) as fp_gxmc1, rtrim(a.fp_gxmc2) as fp_gxmc2, rtrim(a.fp_gxmc3) as fp_gxmc3, rtrim(a.fp_gxmc4) as fp_gxmc4, rtrim(a.fp_gxmc5) as fp_gxmc5, rtrim(a.fp_gxmc6) as fp_gxmc6, 
-        rtrim(a.fp_gxmc7) as fp_gxmc7,rtrim(a.fp_gxmc8) as fp_gxmc8, rtrim(a.fp_gxmc9) as fp_gxmc9, rtrim(a.fp_gxmc10) as fp_gxmc10, rtrim(a.fp_gxmc11) as fp_gxmc11, rtrim(a.fp_gxmc12) as fp_gxmc12, 
-        rtrim(a.fp_gxmc13) as fp_gxmc13,a.qczl_num,a.qczl_yjno,rtrim(b.成品代号) as product_code,rtrim(b.成品名称) as product_name,b.订单数量,rtrim(b.计量单位) as 计量单位,b.实际投料,b.交货日期,
-        c.yj_ls,d.jjcp_sl,d.jjcp_sj
-        ';
-        $where['a.qczl_gdbh'] = $params['order'];
-        $where['a.qczl_yjno'] = $params['yjno'];
-        $where['b.行号'] = 1;
-        $data = db('db_qczl')->alias('a')
-            ->join('工单_基本资料 b','a.qczl_gdbh = b.Gd_gdbh','left')
-            ->join('工单_印件资料 c','a.qczl_gdbh = c.Yj_Gdbh','left')
-            ->join('成品入仓 d','a.qczl_gdbh = d.jjcp_gdbh','left')
-            ->where($where)
-            ->field($field)
-//            ->where('a.qczl_yjno','1')
-            ->group('qczl_yjno,qczl_num')
-            ->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;
-                $gxhKey = "fp_gxmc". $i;
-                if (!empty($entry[$labelKey]) && $entry[$slKey] > 0) {
-                    $list[$j]['fp_lb'] = $entry[$labelKey];
-                    $list[$j]['fp_sl'] = $entry[$slKey];
-                    $list[$j]['fp_bh'] = $entry[$bhKey];
-                    $name = db('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
-                    $list[$j]['fp_name'] =  $name;
-                    $list[$j]['fp_gxh'] = empty(substr($entry[$gxhKey],0,2)) ? "0" : substr($entry[$gxhKey],0,2);
-                    $list[$j]['qczl_num'] = $entry['qczl_num'];
-                    $list[$j]['qczl_yjno'] = $entry['qczl_yjno'];
-                    $list[$j]['product_code'] = $entry['product_code'];
-                    $list[$j]['product_name'] = $entry['product_name'];
-                    $list[$j]['订单数量'] = $entry['订单数量'];
-                    $list[$j]['计量单位'] = $entry['计量单位'];
-                    $list[$j]['交货日期'] = substr($entry['交货日期'],0,10);
-                    $list[$j]['yj_ls'] = $entry['yj_ls'];
-                    $list[$j]['jjcp_sl'] = $entry['jjcp_sl'];
-                    $list[$j]['jjcp_sj'] = substr($entry['jjcp_sj'],0,10);
-                    $j++;
-                }
-            }
-        }
-        $summedData = [];
-        foreach ($list as $item) {
-            $key = $item['qczl_num'] . $item['fp_lb'];
-            if (!isset($summedData[$key])) {
-                $summedData[$key] = $item;
-            } else {
-                $summedData[$key]['fp_sl'] += $item['fp_sl'];
-            }
-        }
-        $fpGxhColumn = array_column($summedData, 'fp_gxh');
-        $qczlNumColumn = array_column($summedData, 'qczl_num');
-        $fpLbColumn = array_column($summedData, 'fp_lb');
-        array_multisort($fpGxhColumn, SORT_ASC, $qczlNumColumn, SORT_ASC, $fpLbColumn, SORT_ASC, $summedData);
-        $summedData = array_values($summedData);
-        $this->success('请求成功',$summedData);
+
     }
 
     /**
-     * 工单核检单删除
-     * @return void
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
+     *
      */
     public function del()
     {
-        if ($this->request->isGet() === false){
-            $this->error('请求错误');
-        }
-        $param = $this->request->param();
-        if (empty($param['UniqId'])){
-            $this->error('参数错误');
-        }
-        $res = \db('db_qczl')
-            ->where('UniqId',$param['UniqId'])
-            ->delete();
-        if ($res !== false){
-            $this->success('删除成功');
-        }else{
-            $this->error('产出失败');
-        }
+
     }
 }

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott