فهرست منبع

系统优化和新功能增加

qiuenguang 10 ماه پیش
والد
کامیت
fbc108db30

+ 155 - 0
application/api/controller/MachineList.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace app\api\controller;
+
+use think\Request;
+use app\common\controller\Api;
+
+/**
+ * 设备维修保养记录
+ */
+
+class MachineList extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+
+    //设备维修保养记录左侧菜单
+    public function getTab()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $year = date('Y',time());
+        $lastYear = date('Y', strtotime('-1 year'));
+        //年度维修统计
+        $yearResult1 = $this->getYearSite($year);
+        $yearResult2 = $this->getYearSite($lastYear);
+        $data['1、年度维修统计'] = [
+            $year => $yearResult1,
+            $lastYear => $yearResult2
+        ];
+        //月度维修记录
+        $lastMouth = date('Y-m', strtotime('-1 year'));
+        $mouthReault = $this->getMouthSite($lastMouth);
+        $data['2、月度维修记录'] = $mouthReault;
+        //年度保养记录
+        $YearMaintenanceSist1 = $this->getYearMaintenanceSist($year);
+        $YearMaintenanceSist2 = $this->getYearMaintenanceSist($lastYear);
+        if (!empty($YearMaintenanceSist1)){
+            $data['3、年度保养统计'][$year] = $YearMaintenanceSist1;
+        }
+        if (!empty($YearMaintenanceSist2)){
+            $data['3、年度保养统计'][$lastYear] = $YearMaintenanceSist2;
+        }
+        //月度保养记录
+        $mouthMaintenanceSist = $this->getMouthMaintenanceSist($lastMouth);
+        $data['4、月度保养记录'] = $mouthMaintenanceSist;
+        $this->success('成功',$data);
+    }
+
+    private function getYearSite($year)
+    {
+        $sist = db('设备_维修记录')
+            ->where('报障时间','like',$year.'%')
+            ->group('使用部门')
+            ->column('rtrim(使用部门)');
+        $data = [];
+        if (!empty($sist)){
+            foreach ($sist as $item){
+                $count = db('设备_维修记录')
+                    ->where('使用部门',$item)
+                    ->where('报障时间','like',$year.'%')
+                    ->count();
+                if ($count !== 0){
+                    $data[] = $item.'('.$count.'台次)';
+                }
+            }
+        }
+        return $data;
+    }
+
+    private function getMouthSite($mouth)
+    {
+        $mouth = db('设备_维修记录')
+            ->where('报障时间','>',$mouth.'-01 00:00:00')
+            ->where('报障时间','<',date('Y-m-d H:i:s',time()))
+            ->group('date')
+            ->order('date desc')
+            ->column('DATE_FORMAT(报障时间, "%Y-%m") AS date');
+        $data = [];
+        foreach ($mouth as $item){
+            $sist = db('设备_维修记录')
+                ->where('报障时间','like',$item.'%')
+                ->group('使用部门')
+                ->column('rtrim(使用部门)');
+            foreach ($sist as $value){
+                $count = db('设备_维修记录')
+                    ->where('使用部门',$value)
+                    ->where('报障时间','like',$item.'%')
+                    ->count();
+                $data[$item][] = $value.'('.$count.'台次)';
+            }
+        }
+        return $data;
+    }
+
+    private function getYearMaintenanceSist($year)
+    {
+        $sist = db('设备_保养记录')
+            ->where('保养开始时间','like',$year.'%')
+            ->group('使用部门')
+            ->column('rtrim(使用部门)');
+        $data = [];
+        if (!empty($sist)){
+            foreach ($sist as $item){
+                $count = db('设备_保养记录')
+                    ->where('使用部门',$item)
+                    ->where('保养开始时间','like',$year.'%')
+                    ->count();
+                if ($count !== 0){
+                    $data[] = $item.'('.$count.'台次)';
+                }
+            }
+        }
+        return $data;
+    }
+
+    private function getMouthMaintenanceSist($mouth)
+    {
+        $mouth = db('设备_保养记录')
+            ->where('保养开始时间','>',$mouth.'-01 00:00:00')
+            ->where('保养开始时间','<',date('Y-m-d H:i:s',time()))
+            ->group('date')
+            ->order('date desc')
+            ->column('DATE_FORMAT(保养开始时间, "%Y-%m") AS date');
+        $data = [];
+        foreach ($mouth as $item){
+            $sist = db('设备_保养记录')
+                ->where('保养开始时间','like',$item.'%')
+                ->group('使用部门')
+                ->column('rtrim(使用部门)');
+            foreach ($sist as $value){
+                $count = db('设备_保养记录')
+                    ->where('使用部门',$value)
+                    ->where('保养开始时间','like',$item.'%')
+                    ->count();
+                $data[$item][] = $value.'('.$count.'台次)';
+            }
+        }
+        return $data;
+    }
+
+    //年度维修记录上方列表
+    public function MachineList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+    }
+}

+ 4 - 2
application/api/controller/OrderSuperLoss.php

@@ -1184,6 +1184,7 @@ class OrderSuperLoss extends Api
                     ->whereOr('b.质量考核', null);
             })
             ->where('c.jjcp_smb', 'like', '末%')
+            ->fetchSql(true)
             ->select();
         $data = [];
 
@@ -1194,7 +1195,7 @@ class OrderSuperLoss extends Api
                 if (!empty($item["sczl_bh{$i}"]) && $item["sczl_bh{$i}"]!== ''){
                     $bh = $item["sczl_bh{$i}"] ?? '';
                     $xm = $item["Xm{$i}"] ?? '';
-                    $rateValue = $item["sczl_rate{$i}"] ?? '';
+                    $rateValue = floatval($item["sczl_rate{$i}"]) ?? '';
 
                     // 关键优化:如果分配比例为 0 或空,默认为 1
                     $rate = (empty($rateValue) || (float)$rateValue == 0) ? 1 : (float)$rateValue;
@@ -1736,7 +1737,8 @@ class OrderSuperLoss extends Api
         b.sys_ny,  
         a.jjcp_gdbh AS Gd_gdbh,  
         a.jjcp_yjno AS jjcp_yjno,  
-        a.jjcp_yjno AS yj_Yjno,  
+        a.jjcp_yjno AS yj_Yjno, 
+        c.yj_Yjdh as yjdh,
         c.yj_ls AS yj_ls,  
         c.yj_cpdh AS 成品编码,  
         c.yj_yjmc AS 成品名称,  

+ 4 - 0
application/api/controller/PowerManagement.php

@@ -5,6 +5,10 @@ use think\Request;
 use app\common\controller\Api;
 
 
+/**
+ * 设备电量管理
+ */
+
 class PowerManagement extends Api
 {
     protected $noNeedLogin = ['*'];

+ 158 - 0
application/api/controller/PrintingPlate.php

@@ -0,0 +1,158 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Request;
+
+/**
+ * 印版库管理
+ */
+
+class PrintingPlate extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+
+    /**
+     * 印版库管理左侧菜单
+     * @return void
+     */
+    public function getTab()
+    {
+        if (!$this->request->isGet()) {
+            $this->error('请求错误');
+        }
+
+        $data = [
+            'MN印版' => $this->buildTree('05'),
+            '翌星印版' => $this->buildTree('Y05')
+        ];
+
+        $this->success('成功', $data);
+    }
+    //私有方法,构建数据
+    private function buildTree($prefix)
+    {
+        $list = db('物料_存货结构')
+            ->where('编号', 'like', $prefix . '%')
+            ->order('编号', 'asc')
+            ->select();
+
+        $map = [];
+        $tree = [];
+
+        // 创建编号映射表
+        foreach ($list as $item) {
+            $map[$item['编号']] = $item['名称'];
+        }
+
+        // 构建树形结构
+        foreach ($list as $item) {
+            $code = $item['编号'];
+            $name = $item['名称'];
+            $key = "{$code} {$name}";
+            $depth = strlen($code) - strlen($prefix);
+
+            switch ($depth) {
+                case 0: // 根节点 (05/Y05)
+                    $tree[$key] = [];
+                    break;
+
+                case 2: // 二级节点 (0501/Y0501)
+                    $parentCode = substr($code, 0, strlen($prefix));
+                    $parentKey = "{$parentCode} {$map[$parentCode]}";
+                    $tree[$parentKey][$key] = [];
+                    break;
+
+                case 4: // 三级节点 (050100/Y050101)
+                    $parentCode = substr($code, 0, strlen($prefix) + 2);
+                    $grandCode = substr($code, 0, strlen($prefix));
+
+                    $grandKey = "{$grandCode} {$map[$grandCode]}";
+                    $parentKey = "{$parentCode} {$map[$parentCode]}";
+
+                    if (isset($tree[$grandKey][$parentKey])) {
+                        $tree[$grandKey][$parentKey][] = $key;
+                    }
+                    break;
+            }
+        }
+        return $tree;
+    }
+
+
+    //存货编码列表
+    public function MaterailCodeList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param) || !isset($param['code'])){
+            $this->error('参数错误');
+        }
+        //截取物料编码,带字母截取前七位,不带字母截取前五位
+        if (preg_match('/[a-zA-Z]/', $param['code'])) {
+
+            $code = substr($param['code'], 0, 7);
+        } else {
+            $code = substr($param['code'], 0, 6);
+        }
+        //根据物料编码分类查询
+
+    }
+
+    public function MaterailDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param) || !isset($param['code'])){
+            $this->error('参数错误');
+        }
+    }
+
+
+    //印版资料修改
+    public function MaterailEdit()
+    {
+        if ($this->request->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param) || !isset($param['code'])){
+            $this->error('参数错误');
+        }
+        $data = [
+            '存货编码'   => $param['code'],
+            '供方批号'   => $param['batch'],
+            '印版名称'   => $param['desc'],
+            '制造日期'   => $param['Manufactur_date'],
+            '原始印数'   => $param['start_num'],
+            '考核印数'   => $param['Assessment_num'],
+            '报废日期'   => $param['Scrappe_date']?:'1900-01-01 00:00:00',
+            'Sys_id'    => $param['sys_id']
+        ];
+        //查询数据是否存在,存在则修改,不存在则增加
+        $res = db('产品_印版库')
+            ->where('存货编码',$param['code'])
+            ->where('供方批号',$param['batch'])
+            ->find();
+        if (empty($res)){
+            $data['Sys_rq'] = date('Y-m-d H:i:s',time());
+            $sql = db('产品_印版库')->fetchSql(true)->insert($data);
+        }else{
+            $data['Mod_rq'] = date('Y-m-d H:i:s',time());
+            $sql = db('产品_印版库')->fetchSql(true)->update($data);
+        }
+        $result = db()->query($sql);
+        if ($result === false){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
+}