Quellcode durchsuchen

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

zck vor 2 Monaten
Ursprung
Commit
fcdfb51586

+ 165 - 157
application/api/controller/CostAccounting.php

@@ -41,11 +41,11 @@ class CostAccounting extends Api
         }
 
         // 3. 数据库查询优化
-        $months = db('成本_各月水电气')
-            ->field('Sys_ny AS year_month')
-            ->group('Sys_ny')
-            ->order('Sys_ny DESC')
-            ->column('Sys_ny');
+        $months = db('成本v23_月度成本明细')
+            ->field('sys_ny AS year_month')
+            ->group('sys_ny')
+            ->order('sys_ny DESC')
+            ->column('sys_ny');
 
         // 4. 使用模板构建策略
         $data = [];
@@ -86,8 +86,6 @@ class CostAccounting extends Api
                 'Sys_ny' => $value['sys_ny'],
                 '车间' => $value['sist'],
                 '一线工资总额' => $value['number'],
-                '系数' => 1.2,
-                '应发工资' => $value['number'] * 1.2,
                 'Sys_id' => $value['sys_id'],
                 'Sys_rq' => date('Y-m-d H:i:s', time())
             ];
@@ -600,18 +598,26 @@ class CostAccounting extends Api
             $this->error('参数错误');
         }
         $data = [];
-        foreach ($param as $k => $v) {
+        $currentTime = date('Y-m-d H:i:s');
+
+        foreach ($param as $item) {
+            // 验证必要字段是否存在
+            if (empty($item['sys_ny']) || empty($item['sist']) || empty($item['科目名称'])) {
+                $this->error('缺少必要参数');
+            }
+
+            // 确保数值字段正确处理为 decimal 类型
             $data[] = [
-                'Sys_ny' => $v['sys_ny'],
-                '部门名称' => $v['sist'],
-                '费用类型' => '分摊',
-                '科目名称' => $v['科目名称'],
-                '耗电量' => $v['耗电量'],
-                '单位电价' => $v['单位电价'],
-                '耗气量' => $v['耗气量'],
-                '单位气价' => $v['单位气价'],
-                'Sys_id' => $v['sys_id'],
-                'Sys_rq' => date('Y-m-d H:i:s', time())
+                'Sys_ny'     => $item['sys_ny'],
+                '部门名称'    => $item['sist'],
+                '费用类型'    => '分摊',
+                '科目名称'    => $item['科目名称'],
+                '耗电量'      => isset($item['耗电量']) ? (float)$item['耗电量'] : 0.00,
+                '单位电价'    => isset($item['单位电价']) ? (float)$item['单位电价'] : 0.00,
+                '耗气量'      => isset($item['耗气量']) ? (float)$item['耗气量'] : 0.00,
+                '单位气价'    => isset($item['单位气价']) ? (float)$item['单位气价'] : 0.00,
+                'Sys_id'     => $item['sys_id'] ?? '',
+                'Sys_rq'     => $currentTime
             ];
         }
         $result = db('成本_各月水电气')->where('Sys_ny', $data[0]['Sys_ny'])->where('费用类型','分摊')->delete();
@@ -706,31 +712,21 @@ class CostAccounting extends Api
     }
 
     //水电气分摊费用下方明细列表
-    public function shuidianqiMachineDetailList()
-    {
-        if ($this->request->isGet() === false) {
-            $this->error('请求错误');
-        }
-        $param = $this->request->param();
-        if (empty($param)) {
-            $this->error('参数错误');
-        }
-        $sist = ['胶印车间','凹丝印车间','印后车间','检验车间'];
-        if (strpos($param['sist'],'车间') === false) {
-            $number = db('成本_各月水电气')
-                ->where('Sys_ny', $param['month'])
-                ->where('部门名称', $param['sist'])
-                ->where('费用类型', '分摊')
-                ->value('');
-        }else{
-            $machineList = db('设备_基本资料')
-                ->where('使用部门', $param['sist'])
-                ->where('sys_sbID', '<>', '')
-                ->order('设备编号')
-                ->column('设备编号');
-        }
-
-    }
+//    public function shuidianqiMachineDetailList()
+//    {
+//        if ($this->request->isGet() === false) {
+//            $this->error('请求错误');
+//        }
+//        $param = $this->request->param();
+//        if (empty($param)) {
+//            $this->error('参数错误');
+//        }
+//        $list = db('设备_基本资料')
+//            ->alias('a')
+//            ->join('成本_各月分摊系数 b', 'a.设备编号 = b.设备编号', 'LEFT')
+//            ->field()
+//
+//    }
 
     /**
      * 其他待摊费用
@@ -899,7 +895,131 @@ class CostAccounting extends Api
 
 
     //计算成本
-    public function CostCalculation()
+//    public function CostCalculation()
+//    {
+//        if ($this->request->isGet() === false) {
+//            $this->error('请求错误');
+//        }
+//        $param = $this->request->param();
+//        if (empty($param)) {
+//            $this->error('参数错误');
+//        }
+//        //查询工单数据
+//        $list = db('成本v23_月度成本明细')
+//            ->field('车间名称,sys_ny as 年月,sczl_gdbh as 工单编号,sczl_yjno as 印件号,sczl_gxh as 工序号,工序名称,sczl_jtbh as jtbh,
+//            占用机时,计件产量,sczl_ms as 墨色数,Uniqid,计件产量*sczl_ms as 色度数')
+//            ->where('sys_ny', $param['month'])
+//            ->whereNotNull('车间名称')
+//            ->select();
+//        //查询整月全车间色度数之和
+//        $ChromaticityCount = db('成本v23_月度成本明细')
+//            ->where('sys_ny', $param['month'])
+//            ->whereNotNull('车间名称')
+//            ->column('sum(计件产量*sczl_ms)');
+//        //查询整月各车间色度数
+//        $MachineChromaticityCount = db('成本v23_月度成本明细')
+//            ->where('sys_ny', $param['month'])
+//            ->whereNotNull('车间名称')
+//            ->group('车间名称')
+//            ->column('sum(计件产量*sczl_ms)');
+//        //计算车间水电气
+//        $res = $this->ApportionmentOne($param['month']);
+//        halt($res);
+//
+//
+//
+//    }
+//    //计算水电气分摊费用
+//    protected function ApportionmentOne($month)
+//    {
+//        $list = db('成本_各月水电气')
+//            ->where('Sys_ny', $month)
+//            ->where('费用类型','like','%分摊%')
+//            ->select();
+//        foreach ($list as $k => $v) {
+//            if ($v['科目名称'] == '待分摊总额') {
+//                $money = $v['耗电量'] * $v['单位电价'];
+//                $data = $this->MachineTime($v['部门名称'],$month);
+//                foreach ($data['machine'] as $k1 => $v1) {
+//                    $data['machine'][$k1]['分摊水电'] = round($money*($v1['占用机时']/$data['sist']),2) ;
+//                }
+//            }elseif (strpos($v['科目名称'],'废气处理') !== false) {
+//                $electricityMoney = $v['耗电量'] * $v['单位电价'];
+//                $gasMoney = $v['耗气量'] * $v['单位气价'];
+//                $data = $this->MachineTime('03、卷凹机组',$month);
+//                foreach ($data['machine'] as $k1 => $v1) {
+//                    $data['machine'][$k1]['分摊水电'] = round($electricityMoney*($v1['占用机时']/$data['sist']),2) ;
+//                    $data['machine'][$k1]['废气处理'] = round($gasMoney*($v1['占用机时']/$data['sist']),2) ;
+//                }
+//            }elseif (strpos($v['科目名称'],'锅炉') !== false && strpos($v['科目名称'],'热水锅炉') === false) {
+//                $electricityMoney = $v['耗电量'] * $v['单位电价'];
+//                $gasMoney = $v['耗气量'] * $v['单位气价'];
+//                $data = $this->MachineTime('03、卷凹机组',$month);
+//                foreach ($data['machine'] as $k1 => $v1) {
+//                    $data['machine'][$k1]['分摊水电'] = round($electricityMoney*($v1['占用机时']/$data['sist']),2) ;
+//                    $data['machine'][$k1]['锅炉'] = round($gasMoney*($v1['占用机时']/$data['sist']),2) ;
+//                }
+//            }elseif (strpos($v['科目名称'],'空压机A') !== false) {
+//                $money = $v['耗电量'] * $v['单位电价'];
+//                $sistList = ['凹丝印车间','胶印车间','印后车间','检验车间'];
+//                $data = $this->MachineTime($sistList,$month);
+//                foreach ($data['machine'] as $k1 => $v1) {
+//                    $data['machine'][$k1]['空压机A'] = round($money*($v1['占用机时']/$data['sist']),2) ;
+//                }
+//            }elseif (strpos($v['科目名称'],'空压机B') !== false) {
+//                $money = $v['耗电量'] * $v['单位电价'];
+//                $sistList = ['凹丝印车间','胶印车间','印后车间','检验车间'];
+//                $data = $this->MachineTime($sistList,$month);
+//                foreach ($data['machine'] as $k1 => $v1) {
+//                    $data['machine'][$k1]['空压机B'] = round($money*($v1['占用机时']/$data['sist']),2) ;
+//                }
+//            }elseif (strpos($v['科目名称'],'热水锅炉') !== false){
+//                $money = $v['耗电量'] * $v['单位电价'];
+//                $sistList = ['凹丝印车间','胶印车间','印后车间','检验车间'];
+//                $data = $this->MachineTime($sistList,$month);
+//                foreach ($data['machine'] as $k1 => $v1) {
+//                    $data['machine'][$k1]['热水锅炉'] = round($money*($v1['占用机时']/$data['sist']),2) ;
+//                }
+//            }
+//        }
+//    }
+//
+//    //查询车间全部机台通电机时数据
+//    protected function MachineTime($sist,$month)
+//    {
+//        $where['a.sys_ny'] = $month;
+//        $where['b.sys_sbID'] = ['<>',''];
+//        if (is_array($sist)) {
+//            $where['a.车间名称'] = ['in',$sist];
+//        }else{
+//            if (strpos($sist,'机组') !== false) {
+//                $where['b.设备编组'] = $sist;
+//            }elseif (strpos($sist,'车间') !== false) {
+//                $where['a.车间名称'] = $sist;
+//            }
+//        }
+//        //查询各个工单工艺通电时间
+//        $machine = db('成本v23_月度成本明细')
+//            ->alias('a')
+//            ->join('设备_基本资料 b', 'a.sczl_jtbh = b.设备编号','left')
+//            ->field('a.sczl_gdbh as 工单编号,a.sczl_yjno as 印件号,a.sczl_gxh as 工序号,a.sczl_jtbh as 机台编号,a.占用机时,a.Uniqid')
+//            ->where($where)
+//            ->select();
+//        //查询各个车间通电总时长
+//        $sist = db('成本v23_月度成本明细')
+//            ->alias('a')
+//            ->join('设备_基本资料 b', 'a.sczl_jtbh = b.设备编号','left')
+//            ->where($where)
+//            ->value('sum(a.占用机时) as 占用机时');
+//        $data = [
+//            'machine' => $machine,
+//            'sist' => $sist
+//        ];
+//        return $data;
+//    }
+
+
+    public function materialRequisition()
     {
         if ($this->request->isGet() === false) {
             $this->error('请求错误');
@@ -908,118 +1028,6 @@ class CostAccounting extends Api
         if (empty($param)) {
             $this->error('参数错误');
         }
-        //查询工单数据
-        $list = db('成本v23_月度成本明细')
-            ->field('车间名称,sys_ny as 年月,sczl_gdbh as 工单编号,sczl_yjno as 印件号,sczl_gxh as 工序号,工序名称,sczl_jtbh as jtbh,
-            占用机时,计件产量,sczl_ms as 墨色数,Uniqid,计件产量*sczl_ms as 色度数')
-            ->where('sys_ny', $param['month'])
-            ->whereNotNull('车间名称')
-            ->select();
-        //查询整月全车间色度数之和
-        $ChromaticityCount = db('成本v23_月度成本明细')
-            ->where('sys_ny', $param['month'])
-            ->whereNotNull('车间名称')
-            ->column('sum(计件产量*sczl_ms)');
-        //查询整月各车间色度数
-        $MachineChromaticityCount = db('成本v23_月度成本明细')
-            ->where('sys_ny', $param['month'])
-            ->whereNotNull('车间名称')
-            ->group('车间名称')
-            ->column('sum(计件产量*sczl_ms)');
-        //计算车间水电气
-        $res = $this->ApportionmentOne($param['month']);
-        halt($res);
-
-
-
-    }
-    //计算水电气分摊费用
-    protected function ApportionmentOne($month)
-    {
-        $list = db('成本_各月水电气')
-            ->where('Sys_ny', $month)
-            ->where('费用类型','like','%分摊%')
-            ->select();
-        foreach ($list as $k => $v) {
-            if ($v['科目名称'] == '待分摊总额') {
-                $money = $v['耗电量'] * $v['单位电价'];
-                $data = $this->MachineTime($v['部门名称'],$month);
-                foreach ($data['machine'] as $k1 => $v1) {
-                    $data['machine'][$k1]['分摊水电'] = round($money*($v1['占用机时']/$data['sist']),2) ;
-                }
-            }elseif (strpos($v['科目名称'],'废气处理') !== false) {
-                $electricityMoney = $v['耗电量'] * $v['单位电价'];
-                $gasMoney = $v['耗气量'] * $v['单位气价'];
-                $data = $this->MachineTime('03、卷凹机组',$month);
-                foreach ($data['machine'] as $k1 => $v1) {
-                    $data['machine'][$k1]['分摊水电'] = round($electricityMoney*($v1['占用机时']/$data['sist']),2) ;
-                    $data['machine'][$k1]['废气处理'] = round($gasMoney*($v1['占用机时']/$data['sist']),2) ;
-                }
-            }elseif (strpos($v['科目名称'],'锅炉') !== false && strpos($v['科目名称'],'热水锅炉') === false) {
-                $electricityMoney = $v['耗电量'] * $v['单位电价'];
-                $gasMoney = $v['耗气量'] * $v['单位气价'];
-                $data = $this->MachineTime('03、卷凹机组',$month);
-                foreach ($data['machine'] as $k1 => $v1) {
-                    $data['machine'][$k1]['分摊水电'] = round($electricityMoney*($v1['占用机时']/$data['sist']),2) ;
-                    $data['machine'][$k1]['锅炉'] = round($gasMoney*($v1['占用机时']/$data['sist']),2) ;
-                }
-            }elseif (strpos($v['科目名称'],'空压机A') !== false) {
-                $money = $v['耗电量'] * $v['单位电价'];
-                $sistList = ['凹丝印车间','胶印车间','印后车间','检验车间'];
-                $data = $this->MachineTime($sistList,$month);
-                foreach ($data['machine'] as $k1 => $v1) {
-                    $data['machine'][$k1]['空压机A'] = round($money*($v1['占用机时']/$data['sist']),2) ;
-                }
-            }elseif (strpos($v['科目名称'],'空压机B') !== false) {
-                $money = $v['耗电量'] * $v['单位电价'];
-                $sistList = ['凹丝印车间','胶印车间','印后车间','检验车间'];
-                $data = $this->MachineTime($sistList,$month);
-                foreach ($data['machine'] as $k1 => $v1) {
-                    $data['machine'][$k1]['空压机B'] = round($money*($v1['占用机时']/$data['sist']),2) ;
-                }
-            }elseif (strpos($v['科目名称'],'热水锅炉') !== false){
-                $money = $v['耗电量'] * $v['单位电价'];
-                $sistList = ['凹丝印车间','胶印车间','印后车间','检验车间'];
-                $data = $this->MachineTime($sistList,$month);
-                foreach ($data['machine'] as $k1 => $v1) {
-                    $data['machine'][$k1]['热水锅炉'] = round($money*($v1['占用机时']/$data['sist']),2) ;
-                }
-            }
-        }
+        
     }
-
-    //查询车间全部机台通电机时数据
-    protected function MachineTime($sist,$month)
-    {
-        $where['a.sys_ny'] = $month;
-        $where['b.sys_sbID'] = ['<>',''];
-        if (is_array($sist)) {
-            $where['a.车间名称'] = ['in',$sist];
-        }else{
-            if (strpos($sist,'机组') !== false) {
-                $where['b.设备编组'] = $sist;
-            }elseif (strpos($sist,'车间') !== false) {
-                $where['a.车间名称'] = $sist;
-            }
-        }
-        //查询各个工单工艺通电时间
-        $machine = db('成本v23_月度成本明细')
-            ->alias('a')
-            ->join('设备_基本资料 b', 'a.sczl_jtbh = b.设备编号','left')
-            ->field('a.sczl_gdbh as 工单编号,a.sczl_yjno as 印件号,a.sczl_gxh as 工序号,a.sczl_jtbh as 机台编号,a.占用机时,a.Uniqid')
-            ->where($where)
-            ->select();
-        //查询各个车间通电总时长
-        $sist = db('成本v23_月度成本明细')
-            ->alias('a')
-            ->join('设备_基本资料 b', 'a.sczl_jtbh = b.设备编号','left')
-            ->where($where)
-            ->value('sum(a.占用机时) as 占用机时');
-        $data = [
-            'machine' => $machine,
-            'sist' => $sist
-        ];
-        return $data;
-    }
-
 }

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

@@ -0,0 +1 @@
+<?php

+ 302 - 0
application/api/controller/EquipmentComponents.php

@@ -0,0 +1,302 @@
+<?php
+
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Request;
+
+/**
+ * 设备部件寿命跟踪
+ */
+class EquipmentComponents extends Api
+{
+    const EXCLUDED_DEPARTMENT = '研发中心';
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 获取车间机台
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getMachineList()
+    {
+        // 1. 使用更清晰的请求方法判断
+        if (!$this->request->isGet()) {
+            $this->error('请求错误');
+        }
+
+        // 3. 统一查询条件,避免重复代码
+        $baseQuery = function() {
+            return \db('设备_基本资料')
+                ->where('设备编组', '<>', '')
+                ->where('sys_sbID', '<>', '');
+        };
+
+        $data = [];
+
+        // 4. 获取部门列表(添加性能优化)
+        $department = $baseQuery()
+            ->distinct(true)
+            ->where('使用部门', '<>', self::EXCLUDED_DEPARTMENT)
+            ->order('设备编组')
+            ->column('使用部门');
+
+        if (empty($department)) {
+            $this->success('未获取到机台数据', []);
+        }
+
+        // 5. 批量查询优化,减少数据库查询次数
+        foreach ($department as $dept) {
+            $trimmedDept = rtrim($dept);
+
+            // 获取该部门下的所有设备编组
+            $benchClasses = $baseQuery()
+                ->where('使用部门', $dept)
+                ->distinct(true)
+                ->order('设备编组')
+                ->column('设备编组');
+
+            foreach ($benchClasses as $benchClass) {
+                $trimmedClass = rtrim($benchClass);
+                if ($trimmedClass === '') {
+                    continue; // 跳过空编组
+                }
+
+                // 获取该编组下的所有设备
+                $machines = $baseQuery()
+                    ->where('使用部门', $dept)
+                    ->where('设备编组', $benchClass)
+                    ->field([
+                        'rtrim(设备编号) as 设备编号',
+                        'rtrim(设备名称) as 设备名称',
+                        '设备编号 as original_id', // 保留原始ID便于调试
+                        '设备名称 as original_name'
+                    ])
+                    ->order('设备编号')
+                    ->select();
+
+                // 6. 使用数组映射简化数据处理
+                $formattedMachines = array_map(function($machine) {
+                    return $machine['设备编号'] . '-->' . $machine['设备名称'];
+                }, $machines);
+
+                if (!empty($formattedMachines)) {
+                    $data[$trimmedDept][$trimmedClass] = $formattedMachines;
+                }
+            }
+        }
+
+        $this->success('成功', $data);
+    }
+
+    /**
+     * 获取组件清单
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getEquipmentList()
+    {
+        if (!$this->request->isGet()) {
+            $this->error('请求错误');
+        }
+        $equipmentList = db('设备_组件清单')
+            ->field('序号,部件编号,部件名称,Uniqid')
+            ->select();
+        if (empty($equipmentList)) {
+            $this->success('未找到组件数据');
+        }
+        foreach ($equipmentList as $key => $equipment) {
+            $equipmentList[$key]['名称'] = $equipment['部件编号'] . '-->' . $equipment['部件名称'];
+        }
+        $this->success('成功', $equipmentList);
+    }
+
+    /**
+     * 创建机台组件配置
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function CreateEquipmentInfo()
+    {
+        if (!$this->request->isPost()) {
+            $this->error('请求错误');
+        }
+        $data = Request::instance()->post();
+        if (empty($data['ids']) || empty($data['jtbh'])) {
+            $this->error('参数错误');
+        }
+        $ids = explode(',',$data['ids']);
+        $equipmentList = db('设备_组件清单')
+            ->field('序号,部件编号,部件名称')
+            ->whereIn('Uniqid',$ids)
+            ->select();
+        db('设备_组件配置清单')->where('设备编号',$data['jtbh'])->delete();
+        $machineEquipmentList = [];
+        foreach ($equipmentList as $equipment) {
+            $machineEquipmentList[] = [
+                '设备编号' => $data['jtbh'],
+                '部件编号' => $equipment['部件编号'],
+                '部件名称' => $equipment['部件名称'],
+                'Sys_id' => $data['sys_id'],
+                'Sys_rq' => date('Y-m-d H:i:s', time()),
+            ];
+        }
+        $sql = db('设备_组件配置清单')->fetchSql(true)->insertAll($machineEquipmentList);
+        $res = \db()->query($sql);
+        if ($res === false){
+            $this->error('创建失败');
+        }else{
+            $this->success('创建成功');
+        }
+    }
+
+    /**
+     * 设备部件寿命跟踪上方列表
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getMachineEquipmentList()
+    {
+        if (!$this->request->isGet()) {
+            $this->error('请求错误');
+        }
+
+        $params = $this->request->param();
+        if (empty($params['machine'])) {
+            $this->error('参数错误');
+        }
+
+        // 优化1:使用链式查询,添加设备编号过滤条件
+        $list = db('设备_组件配置清单')
+            ->alias('a')
+            ->join('设备_组件清单 b', 'a.部件编号 = b.部件编号')
+            ->where('a.设备编号', $params['machine']) // 添加设备编号过滤
+            ->field('a.设备编号,a.部件编号,a.部件名称,a.组件编号,a.小时寿命,a.阈值,a.更换日期,a.Uniqid,b.序号')
+            ->order('b.序号')
+            ->select();
+
+        if (empty($list)) {
+            $this->error('未找到机台部件配置,请先配置部件...');
+        }
+
+        // 优化2:提取有更换日期的记录进行批量查询
+        $hasReplacement = [];
+        foreach ($list as $key => $equipment) {
+            $list[$key]['运行工时'] = 0;
+
+            // 收集需要查询运行工时的设备信息
+            if (!empty($equipment['更换日期'])) {
+                $hasReplacement[$key] = [
+                    'device' => $equipment['设备编号'],
+                    'date' => $equipment['更换日期']
+                ];
+            }
+        }
+
+        // 优化3:批量查询运行工时数据
+        if (!empty($hasReplacement)) {
+            // 按设备编号分组,避免重复查询
+            $deviceRunTimes = [];
+            foreach ($hasReplacement as $item) {
+                $device = $item['device'];
+                $date = $item['date'];
+
+                // 如果该设备还未查询过,则进行查询
+                if (!isset($deviceRunTimes[$device])) {
+                    $deviceRunTimes[$device] = db('设备_产量计酬')
+                        ->where('sczl_jtbh', $device)
+                        ->where('sczl_rq', '>=', $date)
+                        ->field('SUM(sczl_设备运行工时) as total_hours')
+                        ->find();
+                }
+
+                // 为每个记录设置运行工时
+                $key = array_search($item, $hasReplacement);
+                $list[$key]['运行工时'] = $deviceRunTimes[$device]['total_hours'];
+            }
+        }
+
+        $this->success('成功', $list);
+    }
+
+
+    /**
+     * 设备部件寿命下方列表
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getEquipmentDetailList()
+    {
+        if (!$this->request->isGet()) {
+            $this->error('请求错误');
+        }
+        $params = $this->request->param();
+        if (empty($params['machine']) || empty($params['date'])) {
+            $this->error('参数错误');
+        }
+        $list = db('设备_产量计酬')
+            ->alias('a')
+            ->join('工单_印件资料 b', 'a.sczl_gdbh = b.Yj_Gdbh and a.sczl_yjno = b.yj_Yjno')
+            ->field('a.sczl_gdbh as 工单编号,a.sczl_yjno as 印件号,b.yj_yjmc as 印件名称,a.sczl_rq as 日期,SUM(a.sczl_设备运行工时) as 工时,a.sczl_jtbh as 机台编号')
+            ->where([
+                'a.sczl_jtbh' => $params['machine'],
+                'a.sczl_rq' => ['>=', $params['date']],
+            ])
+            ->group('a.sczl_gdbh, a.sczl_yjno')
+            ->select();
+        if (empty($list)) {
+            $this->error('未找到详情数据');
+        }else{
+            $this->success('成功', $list);
+        }
+    }
+
+    /**
+     * 部件数据修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function getEquipmentUpdate()
+    {
+        if (!$this->request->isPost()) {
+            $this->error('请求错误');
+        }
+        $params =  Request::instance()->post();
+        if(empty($params['id'])) {
+            $this->error('参数错误');
+        }
+        $data = [
+            '组件编号' => $params['code'],
+            '小时寿命' => $params['hour'],
+            '更换日期' => $params['date'],
+            '阈值' => $params['number']
+        ];
+        $rql = db('设备_组件配置清单')
+            ->where('Uniqid', $params['id'])
+            ->fetchSql(true)
+            ->update($data);
+        $res = \db()->query($rql);
+        if ($res === false){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
+}