zck 2 zile în urmă
părinte
comite
7cfb796d5a
1 a modificat fișierele cu 100 adăugiri și 112 ștergeri
  1. 100 112
      application/api/controller/Manufacture.php

+ 100 - 112
application/api/controller/Manufacture.php

@@ -1130,61 +1130,61 @@ class Manufacture extends Api
     }
 
  /**
-     * 样衣核批
-     */
-    public function Approval(){
-        if ($this->request->isPost() === false) {
-            $this->error('请求错误');
-        }
-        $param = Request::instance()->post();
-        if (empty($param)) {
-            $this->error('参数错误');
-        }
-        
-        // 判断Uniqid是否为多个,多个以逗号分隔
-        $uniqids = strpos($param['Uniqid'], ',') !== false ? explode(',', $param['Uniqid']) : [$param['Uniqid']];
-        
-        // 获取这些工单对应的月份(用于清除缓存)
-        $months = [];
+ * 样衣核批
+ */
+public function Approval(){
+    if ($this->request->isPost() === false) {
+        $this->error('请求错误');
+    }
+    $param = Request::instance()->post();
+    if (empty($param)) {
+        $this->error('参数错误');
+    }
+    
+    // 判断Uniqid是否为多个,多个以逗号分隔
+    $uniqids = strpos($param['Uniqid'], ',') !== false ? explode(',', $param['Uniqid']) : [$param['Uniqid']];
+    
+    // 获取这些工单对应的月份(用于清除缓存)
+    $months = [];
+    
+    // 准备更新数据(使用数组键名,不需要加反引号)
+    $data = [
+        '审核日期' => !empty($param['rq']) ? $param['rq'] : date('Y-m-d H:i:s'),
+        '审核' => $param['sys_id'],
+    ];
+    
+    // 遍历所有Uniqid进行更新
+    foreach ($uniqids as $uniqid) {
+        // 先查询该工单的落货日期(货期),获取月份
+        $orderInfo = Db::table('工单_基本资料')
+            ->where('Uniqid', $uniqid)
+            ->field('落货日期')
+            ->find();
         
-        // 遍历所有Uniqid进行更新
-        foreach ($uniqids as $uniqid) {
-            // 先查询该工单的落货日期(货期),获取月份
-            $orderInfo = Db::table('工单_基本资料')
-                ->where('Uniqid', $uniqid)
-                ->field('落货日期')
-                ->find();
-            
-            if ($orderInfo && !empty($orderInfo['落货日期'])) {
-                $month = date('Y-m', strtotime($orderInfo['落货日期']));
-                $months[$month] = $month;
-            }
-            
-            // 准备更新数据
-            $data = [
-                '审核日期' => !empty($param['rq']) ? $param['rq'] : date('Y-m-d H:i:s'),
-                '审核' => $param['sys_id'],
-            ];
-            
-            // 执行更新
-            $res = Db::table('工单_基本资料')
-                ->where('Uniqid', $uniqid)
-                ->update($data);
-            
-            // 如果更新失败,直接返回错误
-            if ($res === false) {
-                $this->error('审核失败');
-            }
+        if ($orderInfo && !empty($orderInfo['落货日期'])) {
+            $month = date('Y-m', strtotime($orderInfo['落货日期']));
+            $months[$month] = $month;
         }
         
-        // 清除相关月份的缓存
-        foreach ($months as $month) {
-            $this->clearWorkOrderCache($month);
-        }
+        // 执行更新(使用数组方式,不要用fetchSql)
+        $res = Db::table('工单_基本资料')
+            ->where('Uniqid', $uniqid)
+            ->update($data);
         
-        // 所有更新操作都成功时,返回成功
-        $this->success('审核成功');
+        // 如果更新失败,直接返回错误
+        if ($res === false) {
+            $this->error('审核失败');
+        }
+    }
+    
+    // 清除相关月份的缓存
+    foreach ($months as $month) {
+        $this->clearWorkOrderCache($month);
     }
+    
+    // 所有更新操作都成功时,返回成功
+    $this->success('审核成功');
+}
 
    
 
@@ -1301,74 +1301,62 @@ class Manufacture extends Api
         $this->success('成功', $data);
     }
 
-     /**
-     * 辅料计划入库时间更新
-     */
-    public function AccessoriesInboundTime(){
-        if ($this->request->isPost() === false) {
-            $this->error('请求错误');
-        }
-        $param = Request::instance()->post();
-        if (empty($param)) {
-            $this->error('参数错误');
-        }
-        
-        // 判断Uniqid是否为多个,多个以逗号分隔
-        $uniqids = strpos($param['Uniqid'], ',') !== false ? explode(',', $param['Uniqid']) : [$param['Uniqid']];
-        
-        // 获取这些工单对应的月份(用于清除缓存)
-        $months = [];
+    /**
+ * 辅料计划入库时间更新
+ */
+public function AccessoriesInboundTime(){
+    if ($this->request->isPost() === false) {
+        $this->error('请求错误');
+    }
+    $param = Request::instance()->post();
+    if (empty($param)) {
+        $this->error('参数错误');
+    }
+    
+    // 判断Uniqid是否为多个,多个以逗号分隔
+    $uniqids = strpos($param['Uniqid'], ',') !== false ? explode(',', $param['Uniqid']) : [$param['Uniqid']];
+    
+    // 获取这些工单对应的月份(用于清除缓存)
+    $months = [];
+    
+    // 准备更新数据(使用数组键名,不需要加反引号)
+    $data = [
+        '辅料计划入库时间' => !empty($param['rq']) ? $param['rq'] : date('Y-m-d H:i:s'),
+        '辅料计划入库操作人' => $param['sys_id'],
+    ];
+    
+    // 遍历所有Uniqid进行更新
+    foreach ($uniqids as $uniqid) {
+        // 先查询该工单的落货日期(货期),获取月份
+        $orderInfo = Db::table('工单_基本资料')
+            ->where('Uniqid', $uniqid)
+            ->field('落货日期')
+            ->find();
         
-        // 遍历所有Uniqid进行更新
-        foreach ($uniqids as $uniqid) {
-            // 先查询该工单的落货日期(货期),获取月份
-            $orderInfo = Db::table('工单_基本资料')
-                ->where('Uniqid', $uniqid)
-                ->field('落货日期')
-                ->find();
-            
-            if ($orderInfo && !empty($orderInfo['落货日期'])) {
-                $month = date('Y-m', strtotime($orderInfo['落货日期']));
-                $months[$month] = $month; // 使用数组去重
-            }
-            
-            // 准备更新数据
-            $data = [
-                '辅料计划入库时间' => !empty($param['rq']) ? $param['rq'] : date('Y-m-d H:i:s'),
-                '辅料计划入库操作人' => $param['sys_id'],
-            ];
-            
-            // 执行更新
-            $res = Db::table('工单_基本资料')
-                ->where('Uniqid', $uniqid)
-                ->update($data);
-            
-            // 如果更新失败,直接返回错误
-            if ($res === false) {
-                $this->error('更新辅料计划入库时间失败');
-            }
+        if ($orderInfo && !empty($orderInfo['落货日期'])) {
+            $month = date('Y-m', strtotime($orderInfo['落货日期']));
+            $months[$month] = $month;
         }
         
-        // 清除相关月份的缓存
-        foreach ($months as $month) {
-            $this->clearWorkOrderCache($month);
-        }
+        // 执行更新(使用数组方式,不要用fetchSql)
+        $res = Db::table('工单_基本资料')
+            ->where('Uniqid', $uniqid)
+            ->update($data);
         
-        // 所有更新操作都成功时,返回成功
-        $this->success('更新成功');
+        // 如果更新失败,直接返回错误
+        if ($res === false) {
+            $this->error('更新辅料计划入库时间失败');
+        }
     }
-
-     /**
-     * 清除工单数据缓存(内部方法)
-     * @param string $rq 月份(Y-m格式)
-     */
-    private function clearWorkOrderCache($rq)
-    {
-        if (empty($rq)) return;
-        
-        $cacheKey = 'work_orders_' . $rq;
-        cache($cacheKey, null);
+    
+    // 清除相关月份的缓存
+    foreach ($months as $month) {
+        $this->clearWorkOrderCache($month);
     }
+    
+    // 所有更新操作都成功时,返回成功
+    $this->success('更新成功');
+}
 
     /**
      * 月度客户订单汇总