Parcourir la source

印版库管理下方菜单

unknown il y a 9 mois
Parent
commit
0551d1df24
1 fichiers modifiés avec 35 ajouts et 3 suppressions
  1. 35 3
      application/api/controller/PrintingPlate.php

+ 35 - 3
application/api/controller/PrintingPlate.php

@@ -409,10 +409,42 @@ class PrintingPlate extends Api
         }
         $list = db('产品_印版资料')
             ->alias('a')
-            ->field('rtrim(a.YB_Cpdh) as 产品代号,rtrim(b.产品名称) as 产品名称,b.')
+            ->field('
+                rtrim(a.YB_Cpdh) as 产品代号,
+                rtrim(b.产品名称) as 产品名称,
+                rtrim(b.客户编号) as 客户编号,
+                rtrim(b.客户名称) as 客户名称,
+                rtrim(a.存货编码) as 存货编码,
+                rtrim(c.名称) as 名称
+            ')
             ->join('产品_基本资料 b', 'a.YB_Cpdh = b.产品编号')
-            ->group('a.YB_Cpdh')
+            ->join('物料_存货结构 c',
+                "(CASE 
+                    WHEN a.存货编码 REGEXP '[A-Za-z]' 
+                    THEN LEFT(rtrim(a.存货编码), 5) 
+                    ELSE LEFT(rtrim(a.存货编码), 4) 
+                END) = rtrim(c.编号)"
+            )
+            ->group('a.YB_Cpdh,名称')
+            ->order('a.YB_Cpdh,a.存货编码')
             ->select();
-        halt($list);
+        if (empty($list)){
+            $this->error('未找到客户数据');
+        }
+        foreach ($list as $item) {
+            $customerKey = $item['客户编号'] . '【' . $item['客户名称'] . '】';
+            $productKey = $item['产品代号'] . '【' . $item['产品名称'] . '】';
+            if (!isset($data[$customerKey])) {
+                $data[$customerKey] = [];
+            }
+            if (!isset($data[$customerKey][$productKey])) {
+                $data[$customerKey][$productKey] = [];
+            }
+            if (!in_array($item['名称'], $data[$customerKey][$productKey])) {
+                $data[$customerKey][$productKey][] = $item['名称'];
+            }
+        }
+        $this->success('成功', $data);
     }
+
 }