Ver código fonte

设备优化

unknown 1 mês atrás
pai
commit
e784264922

+ 1 - 1
application/api/controller/MachineList.php

@@ -412,7 +412,7 @@ class MachineList extends Api
             ->field('rtrim(a.设备编号) as 设备编号,rtrim(a.设备名称) as 设备名称,a.报障时间,a.维修受理时间,a.修复时间,a.实际维修工时 as 故障维修工时,rtrim(a.验收情况) as 验收情况,
             rtrim(b.员工姓名) as 机长,rtrim(c1.员工姓名) as 维修姓名1,rtrim(c2.员工姓名) as 维修姓名2,rtrim(c3.员工姓名) as 维修姓名3,rtrim(c4.员工姓名) as 维修姓名4,
             a.维修人员1,a.维修人员2,a.维修人员3,a.维修人员4,
-            rtrim(a.故障现象) as 故障现象,rtrim(a.处理方法) as 处理方法,rtrim(a.使用部门) as 使用部门,a.sys_id as 创建用户,a.sys_rq as 创建时间,a.mod_rq as 修改时间,a.UniqId');
+            rtrim(a.故障现象) as 故障现象,rtrim(a.处理方法) as 处理方法,rtrim(a.使用部门) as 使用部门,a.验收人,a.sys_id as 创建用户,a.sys_rq as 创建时间,a.mod_rq as 修改时间,a.UniqId');
         for($i=1;$i<=4;$i++){
             $tableNumber = 'c'.$i;
             $field = 'a.维修人员'.$i;

+ 9 - 63
application/api/controller/PowerManagement.php

@@ -31,15 +31,16 @@ class PowerManagement extends Api
 
         // 获取月份数据
         $months = db('设备_产量计酬')
-            ->where('sczl_rq', '>', $newMonth . '-01 00:00:00')
+            ->where('开工时间', '>', $newMonth . '-01 00:00:00')
             ->group('mouth')
             ->order('mouth desc')
-            ->column('DATE_FORMAT(sczl_rq, "%Y%m") AS mouth');
+            ->column('DATE_FORMAT(开工时间, "%Y%m") AS mouth');
 
         // 获取所有车间名称
         $workShops = db('设备_基本资料')
             ->whereNotNull('sys_sbID')
             ->where('sys_sbID', '<>', '')
+            ->where('使用部门','<>','检验车间')
             ->distinct('使用部门')
             ->column('使用部门');
 
@@ -58,62 +59,6 @@ class PowerManagement extends Api
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      */
-//    public function MachineList()
-//    {
-//        // 判断请求方式是否为GET
-//        if (!$this->request->isGet()) {
-//            return $this->error('请求错误');
-//        }
-//
-//        // 获取请求参数
-//        $params = $this->request->param();
-//
-//        // 检查必需参数
-//        if (empty($params) || !isset($params['mouth'])) {
-//            return $this->error('参数错误');
-//        }
-//
-//        // 转换为标准日期格式
-//        $month = substr($params['mouth'], 0, 4) . '-' . substr($params['mouth'], 4, 2);
-//
-//        // 构建查询条件
-//        $conditions = [];
-//        if (!empty($params['workShop'])) {
-//            $conditions['使用部门'] = $params['workShop'];
-//        }
-//
-//        // 获取机台列表
-//        $machineList = db('设备_基本资料')
-//            ->where($conditions)
-//            ->whereNotNull('sys_sbID')
-//            ->where('sys_sbID', '<>', '')
-//            ->order('设备编组, 设备编号')
-//            ->column('rtrim(设备名称)', '设备编号');
-//
-//        // 准备数据容器
-//        $data = [];
-//
-//        // 查询电表数据
-//        foreach ($machineList as $machineId => $machineName) {
-//            $lastData = $this->getMeterData($machineId, date('Y-m', strtotime($month . ' -1 month')));
-//            $newData = $this->getMeterData($machineId, $month);
-//
-//            if (!empty($lastData) || !empty($newData)) {
-//                $res = [
-//                    'MachineCode' => $machineId,
-//                    'MachineName' => $machineName,
-//                    'lastMain' => $lastData['主电表'] ?? 0,
-//                    'lastAuxiliary' => $lastData['辅电表'] ?? 0,
-//                    'newMain' => $newData['主电表'] ?? 0,
-//                    'newAuxiliary' => $newData['辅电表'] ?? 0
-//                ];
-//                $res['mainNumber'] = $res['newMain'] - $res['lastMain'];
-//                $res['auxiliaryNumber'] = $res['newAuxiliary'] - $res['lastAuxiliary'];
-//                $data[] = $res;
-//            }
-//        }
-//        $this->success('成功',$data);
-//    }
     public function MachineList()
     {
         // 判断请求方式是否为GET
@@ -138,6 +83,7 @@ class PowerManagement extends Api
         // 获取机台列表
         $machineList = db('设备_基本资料')
             ->where($conditions)
+            ->whereNotLike('设备编号', 'YQZ%')
             ->whereNotNull('sys_sbID')
             ->where('sys_sbID', '<>', '')
             ->order('设备编组, 设备编号')
@@ -183,8 +129,8 @@ class PowerManagement extends Api
         foreach ($months as $month) {
             $data = db('设备_产量计酬') // 替换为真实的电表数据表
             ->whereIn('sczl_jtbh', $machineIds)
-                ->where('sczl_rq', '>=', $month . '-01')
-                ->where('sczl_rq', '<=', $month . '-' . date('t', strtotime($month)))
+                ->where('开工时间', '>=', $month . '-01')
+                ->where('开工时间', '<=', $month . '-' . date('t', strtotime($month)))
                 ->select();
 
             // 按设备编号和月份分组存储
@@ -211,7 +157,7 @@ class PowerManagement extends Api
     {
         return db('设备_产量计酬')
             ->field('主电表, 辅电表')
-            ->where('sczl_rq', 'like', "$date%")
+            ->where('开工时间', 'like', "$date%")
             ->where('主电表', '<>', 0)
             ->where('辅电表', '<>', 0)
             ->where('sczl_jtbh', $machineId)
@@ -239,7 +185,7 @@ class PowerManagement extends Api
         // 转换为标准日期格式
         $month = substr($param['mouth'], 0, 4) . '-' . substr($param['mouth'], 4, 2);
         $where = [
-            'sczl_rq' => ['like',$month.'%'],
+            '开工时间' => ['like',$month.'%'],
             'sczl_jtbh' => $param['machine'],
             '主电表' => ['<>',0]
         ];
@@ -249,7 +195,7 @@ class PowerManagement extends Api
             ->order('开工时间 desc')
             ->select();
         if (empty($list)){
-            $this->error('为找打数据');
+            $this->error('未找到数据');
         }else{
             $this->success('成功',$list);
         }