浏览代码

日产量数据班组信息批量修改

qiuenguang 1 年之前
父节点
当前提交
5e642c2aef
共有 1 个文件被更改,包括 42 次插入3 次删除
  1. 42 3
      application/api/controller/Facility.php

+ 42 - 3
application/api/controller/Facility.php

@@ -2028,9 +2028,12 @@ class Facility extends Api
         if (empty($param['UniqId'])){
             $this->error('参数错误');
         }
-        $res = \db('设备_产量计酬')
-            ->where('UniqId',$param['UniqId'])
-            ->delete();
+        $idList = explode(',',$param['UniqId']);
+        foreach ($idList as $key=>$value){
+            $res = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->delete();
+        }
         if ($res !== false){
             $this->success('删除成功');
         }else{
@@ -2296,4 +2299,40 @@ class Facility extends Api
         }
     }
 
+    //日产量上报班组信息批量修改
+    public function YieldTeamEdit()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['Uniqid']) || empty($param['teamID'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$param['Uniqid']);
+        $teamList = \db('设备_班组资料')->where('UniqId',$param['teamID'])->find();
+        $data = [];
+        for ($i=1;$i<11;$i++){
+            $data['sczl_bh'.$i] = $teamList['sczl_bh'.$i];
+            $data['sczl_rate'.$i] = $teamList['sczl_rate'.$i];
+            $data['sczl_bzdh'] = $teamList['sczl_bzdh'];
+        }
+        $j = 0;
+        foreach ($idList as $key => $value){
+            $sql = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->fetchSql(true)
+                ->update($data);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $j++;
+            }
+        }
+        if ($j === 0){
+            $this->success('修改成功');
+        }else{
+            $this->error('修改失败');
+        }
+    }
+
 }