qiuenguang 11 месяцев назад
Родитель
Сommit
184c6db5f2
1 измененных файлов с 18 добавлено и 18 удалено
  1. 18 18
      application/api/controller/OrderSuperLoss.php

+ 18 - 18
application/api/controller/OrderSuperLoss.php

@@ -1163,34 +1163,34 @@ class OrderSuperLoss extends Api
      */
     public function EmployeeDataCollect()
     {
-        if ($this->request->isPost() === false){
+        if ($this->request->isPost() === false) {
             $this->error('请求错误');
         }
         $params = $this->request->post();
-        if (empty($params)){
+        if (empty($params)) {
             $this->error('参数错误');
         }
-        $date = date('Ym',strtotime($params['date']));
+        $date = date('Ym', strtotime($params['date']));
         $list = \db('工单_质量考核汇总')
             ->alias('a')
-            ->join('工单_印件资料 b','a.Gy0_gdbh = b.Yj_Gdbh AND a.印件及工序 = b.yj_Yjno')
-            ->where('a.sys_ny',$date)
-            ->where('b.质量考核',0)
+            ->join('工单_印件资料 b', 'a.Gy0_gdbh = b.Yj_Gdbh AND a.印件及工序 = b.yj_Yjno')
+            ->where('a.sys_ny', $date)
+            ->where('b.质量考核', 0)
             ->select();
         $data = [];
-        foreach ($list as $item){
-            for ($i = 1; $i <9; $i++){
-                if ($item['sczl_bh'.$i] !== '' && $item['sczl_bh'.$i] !== null && $item['sczl_bh'.$i] !== '0000'){
-                    if ($item['sczl_rate'.$i] === null){
-                        $item['sczl_rate'.$i] = 1;
+        foreach ($list as $item) {
+            for ($i = 1; $i < 9; $i++) {
+                if ($item['sczl_bh' . $i] !== '' && $item['sczl_bh' . $i] !== null && $item['sczl_bh' . $i] !== '0000') {
+                    if ($item['sczl_rate' . $i] === null) {
+                        $item['sczl_rate' . $i] = 1;
                     }
                     $res = [
-                        'bh' => $item['sczl_bh'.$i],
-                        'xm' => $item['Xm'.$i],
-                        'je' => $item['CjsJe']*$item['sczl_rate'.$i],
+                        'bh' => $item['sczl_bh' . $i],
+                        'xm' => $item['Xm' . $i],
+                        'je' => $item['CjsJe'] * $item['sczl_rate' . $i],
                         'cj' => rtrim($item['车间名称'])
                     ];
-                    array_push($data,$res);
+                    array_push($data, $res);
                 }
             }
         }
@@ -1198,7 +1198,7 @@ class OrderSuperLoss extends Api
         foreach ($data as $item) {
             $cj = $item['cj'];
             $bh = $item['bh'];
-            $je = intval($item['je']);
+            $je = intval($item['je']); // 保留为整数格式
 
             // 如果 cj 不存在于结果数组中,则初始化
             if (!isset($result[$cj])) {
@@ -1220,12 +1220,12 @@ class OrderSuperLoss extends Api
                 $result[$cj][] = array(
                     'bh' => $bh,
                     'xm' => $item['xm'],
-                    'je' => number_format($je, 2), // 保留两位小数
+                    'je' => (float)$je, // 保留为浮点数格式
                     'cj' => $cj
                 );
             }
         }
-        $this->success('成功',$result);
+        $this->success('成功', $result);
     }