Przeglądaj źródła

订单修改和月度报表

qiuenguang 1 rok temu
rodzic
commit
9ad7a1c088

+ 26 - 6
application/api/controller/Manufacture.php

@@ -1049,17 +1049,37 @@ class Manufacture extends Api
         }
         $time = date('Y-m',strtotime($param['mouth']));
         $where['b.Sys_rq'] = ['like',$time.'%'];
-        $list = \db('工单_印件资料')
+        $list = \db('设备_产量计酬')
             ->alias('a')
             ->join('工单_基本资料 b','a.订单编号 = b.订单编号')
-            ->join('设备_产量计酬 c','a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号','left')
-            ->field('a.订单编号,a.子订单编号,a.款号,a.颜色,a.zdtotal as 制单总数,a.sctotal as 裁切总数,a.ck_rq as 出库日期,
-            SUM(c.数量) as 车缝产量,c.后道,c.大烫,c.总检,c.包装')
+            ->join('工单_印件资料 c','a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号')
+            ->field('c.订单编号,c.子订单编号,c.款号,c.颜色,c.zdtotal as 制单总数,c.sctotal as 裁切总数,c.ck_rq as 出库日期,
+            SUM(a.数量) as 产量,a.工序名称')
+            ->where($where)
+            ->group('a.订单编号,a.工序名称')
+            ->order('c.Uniqid')
+            ->select();
+        $orderList = \db('设备_产量计酬')
+            ->alias('a')
+            ->join('工单_基本资料 b','a.订单编号 = b.订单编号')
+            ->join('工单_印件资料 c','a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号')
+            ->field('c.订单编号,c.子订单编号,c.款号,c.颜色,c.zdtotal as 制单总数,c.sctotal as 裁切总数,c.ck_rq as 出库日期')
             ->where($where)
             ->group('a.子订单编号')
-            ->order('a.Uniqid')
+            ->order('c.Uniqid')
             ->select();
-        $this->success('成功',$list);
+        $data=[];
+        foreach ($orderList as $key=>$value){
+            $data[$key] = $value;
+            foreach ($list as $k=>$v){
+                if ($value['子订单编号'] === $v['子订单编号']){
+                    if (isset($data[$key][$v['工序名称']]) === false){
+                        $data[$key][$v['工序名称']] = $v['产量'];
+                    }
+                }
+            }
+        }
+        $this->success('成功',$data);
     }
 
     /**

+ 90 - 0
application/api/controller/WorkOrder.php

@@ -2250,4 +2250,94 @@ class WorkOrder extends Api
         $this->success('成功',$newOrder);
     }
 
+    /**
+     * 获取子订单编号
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getSuborder()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $data = \db('工单_印件资料')
+            ->where('订单编号',$param['order'])
+            ->order('子订单编号 desc')
+            ->find();
+        $num = (int)substr($data['子订单编号'],10) + 1;
+        if ($num<10){
+            $order = $param['order'].'-0'.$num;
+        }else{
+            $order = $param['order'].'-'.$num;
+        }
+        $this->success('成功',$order);
+    }
+
+
+    /**
+     * 订单资料修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function WorkOrderEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $id = $param['id'];
+        unset($param['id']);
+        $sql = \db('工单_基本资料')
+            ->where('Uniqid',$id)
+            ->fetchSql(true)
+            ->update($param);
+        $res = \db()->query($sql);
+        if ($res === false){
+            $this->error('失败');
+        }else{
+            $this->success('成功');
+        }
+    }
+
+
+    /**
+     * 颜色资料修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function PrintDataEdit()
+    {
+        if(Request::instance()->post() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $id = $param['id'];
+        unset($param['id']);
+        $sql = \db('工单_印件资料')
+            ->where('Uniqid',$id)
+            ->fetchSql(true)
+            ->update($param);
+        $res = \db()->query($sql);
+        if ($res === false){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
 }