liuhairui 1 月之前
父節點
當前提交
9a7f19f28b

+ 14 - 5
application/api/controller/Manufacture.php

@@ -1142,11 +1142,20 @@ class Manufacture extends Api
         }
         // 判断Uniqid是否为多个,多个以逗号分隔
         $uniqids = strpos($param['Uniqid'], ',') !== false ? explode(',', $param['Uniqid']) : [$param['Uniqid']];
-        // 准备更新数据
-        $data = [
-            '审核日期' => date('Y-m-d H:i:s'),
-            '审核' => $param['sys_id'],
-        ];
+
+        if (!empty($param['rq'])) {
+            // 准备更新数据
+            $data = [
+                '审核日期' => $param['rq'],
+                '审核' => $param['sys_id'],
+            ];
+        }else{
+            // 准备更新数据
+            $data = [
+                '审核日期' => date('Y-m-d H:i:s'),
+                '审核' => $param['sys_id'],
+            ];
+        }
         // 遍历所有Uniqid进行更新
         foreach ($uniqids as $uniqid) {
             $list = \db('工单_基本资料')

+ 118 - 98
application/api/controller/OrderSuperLoss.php

@@ -27,119 +27,139 @@ class OrderSuperLoss extends Api
 
 
     /**
- * 获取工单接单日期的年月列表(左侧菜单栏)
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
-public function getWorkOrderDates()
-{
-    if ($this->request->isGet() === false) {
-        $this->error('请求错误');
-    }
-
-    $list = \think\Db::table('工单_基本资料')
-        ->whereNull('Mod_rq')  // 排除 Mod_rq 不为 null 的数据
-        ->where('落货日期', '<>', '')  // 排除空值
-        ->field(\think\Db::raw('DATE_FORMAT(落货日期, "%Y-%m") as 年月'))
-        ->group('年月')
-        ->order('年月', 'desc')  // 按年月倒序排列,最新的在前面
-        ->select();
+     * 获取工单接单日期的年月列表(左侧菜单栏)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getWorkOrderDates()
+    {
+        if ($this->request->isGet() === false) {
+            $this->error('请求错误');
+        }
 
-    if (empty($list)) {
-        $this->success('', []);
-    }
+        $list = \think\Db::table('工单_基本资料')
+            ->whereNull('Mod_rq')  // 排除 Mod_rq 不为 null 的数据
+            ->where('落货日期', '<>', '')  // 排除空值
+            ->field(\think\Db::raw('DATE_FORMAT(落货日期, "%Y-%m") as 年月'))
+            ->group('年月')
+            ->order('年月', 'desc')  // 按年月倒序排列,最新的在前面
+            ->select();
 
-    // 提取年月值组成数组
-    $data = [];
-    foreach ($list as $item) {
-        $data[] = $item['年月'];
-    }
+        if (empty($list)) {
+            $this->success('', []);
+        }
 
-    $this->success('成功', $data);
-}
+        // 提取年月值组成数组
+        $data = [];
+        foreach ($list as $item) {
+            $data[] = $item['年月'];
+        }
 
-/**
- * 根据月份获取工单数据(排除已修改记录)
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
-public function getWorkOrdersByMonth()
-{
-    if ($this->request->isGet() === false) {
-        $this->error('请求错误');
+        $this->success('成功', $data);
     }
 
-    $rq = $this->request->get('rq');
-    if (empty($rq) || !preg_match('/^\d{4}-\d{2}$/', $rq)) {
-        $this->error('参数格式错误,请使用 YYYY-MM 格式');
-    }
+    /**
+     * 根据月份获取工单数据(排除已修改记录)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getWorkOrdersByMonth()
+    {
+        if ($this->request->isGet() === false) {
+            $this->error('请求错误');
+        }
+
+        $rq = $this->request->get('rq');
+        if (empty($rq) || !preg_match('/^\d{4}-\d{2}$/', $rq)) {
+            $this->error('参数格式错误,请使用 YYYY-MM 格式');
+        }
 
-    // 计算月份起止日期
-    list($year, $month) = explode('-', $rq);
-    $start = "{$year}-{$month}-01";
-    $end = date('Y-m-d', strtotime("{$year}-{$month}-01 +1 month"));
-
-    $list = \think\Db::table('工单_基本资料')
-        ->alias('g')
-        ->join('库存_出入库明细 d', 'g.订单编号 = d.order_id', 'LEFT')
-        ->join('设备_产量计酬 c', 'g.订单编号 = c.订单编号', 'LEFT')
-        ->where('g.落货日期', '>=', $start)
-        ->where('g.落货日期', '<', $end)
-        ->whereNull('g.Mod_rq')
-        ->whereNull('c.Mod_rq')
-        ->field([
-            'g.接单日期 as 下单日期',
-            'g.落货日期 as 货期',
-            'g.生产款号 as 款号',
-            'g.订单数量',
-            'g.工单入仓数量 as 入库数量',
-            'g.款式',
-            'g.客户编号 as 客人编号',
-            \think\Db::raw('MIN(CASE WHEN d.name = "入库" THEN d.rq END) as 面料入库时间'),
-            \think\Db::raw('MIN(CASE WHEN c.工序名称 = "裁剪" THEN c.sczl_rq END) as 开裁日期'),
-            \think\Db::raw('SUM(CASE WHEN c.工序名称 = "裁剪" THEN c.数量 ELSE 0 END) as 实裁数量'),
-            \think\Db::raw('MIN(CASE WHEN c.工序名称 = "车缝" THEN c.sczl_rq END) as 上车位日期'),
-            \think\Db::raw('MIN(CASE WHEN c.工序名称 = "车缝" AND c.尾包 = 1 THEN c.sczl_rq END) as 车位完成日期'),
-            \think\Db::raw('MIN(CASE WHEN c.工序名称 = "手工" AND c.尾包 = 1 THEN c.sczl_rq END) as 后道完成日期'),
-            \think\Db::raw('SUM(CASE WHEN c.工序名称 = "包装" THEN c.数量 ELSE 0 END) as 已完成数量'),
-            // 生产组别:只从车缝工序获取,使用子查询
-            \think\Db::raw('(SELECT GROUP_CONCAT(DISTINCT SUBSTRING(sczl_jtbh, 3, 2) ORDER BY SUBSTRING(sczl_jtbh, 3, 2) SEPARATOR "、") 
+        // 计算月份起止日期
+        list($year, $month) = explode('-', $rq);
+        $start = "{$year}-{$month}-01";
+        $end = date('Y-m-d', strtotime("{$year}-{$month}-01 +1 month"));
+
+        $list = \think\Db::table('工单_基本资料')
+            ->alias('g')
+            ->join('库存_出入库明细 d', 'g.订单编号 = d.order_id', 'LEFT')
+            ->where('g.落货日期', '>=', $start)
+            ->where('g.落货日期', '<', $end)
+            ->whereNull('g.Mod_rq')
+            ->field([
+                'g.Uniqid',
+                'g.订单编号',
+                'g.审核 as 核批',
+                'g.审核日期 as 核批日期',
+                'g.接单日期 as 下单日期',
+                'g.落货日期 as 货期',
+                'g.生产款号 as 款号',
+                'g.订单数量',
+                'g.工单入仓数量 as 入库数量',
+                'g.款式',
+                'g.客户编号 as 客人编号',
+
+                // 面料入库时间 - 使用子查询避免重复
+                \think\Db::raw('(SELECT MIN(rq) FROM 库存_出入库明细 WHERE order_id = g.订单编号 AND name = "入库") as 面料入库时间'),
+
+                // 裁剪相关 - 使用子查询
+                \think\Db::raw('(SELECT MIN(sczl_rq) FROM 设备_产量计酬 WHERE 订单编号 = g.订单编号 AND 工序名称 = "裁剪" AND Mod_rq IS NULL) as 开裁日期'),
+                \think\Db::raw('(SELECT SUM(数量) FROM 设备_产量计酬 WHERE 订单编号 = g.订单编号 AND 工序名称 = "裁剪" AND Mod_rq IS NULL) as 实裁数量'),
+
+                // 车缝相关 - 使用子查询
+                \think\Db::raw('(SELECT MIN(sczl_rq) FROM 设备_产量计酬 WHERE 订单编号 = g.订单编号 AND 工序名称 = "车缝" AND Mod_rq IS NULL) as 上车位日期'),
+                \think\Db::raw('(SELECT MIN(sczl_rq) FROM 设备_产量计酬 WHERE 订单编号 = g.订单编号 AND 工序名称 = "车缝" AND 尾包 = 1 AND Mod_rq IS NULL) as 车位完成日期'),
+
+                // 后道相关 - 使用子查询
+                \think\Db::raw('(SELECT MIN(sczl_rq) FROM 设备_产量计酬 WHERE 订单编号 = g.订单编号 AND 工序名称 = "手工" AND 尾包 = 1 AND Mod_rq IS NULL) as 后道完成日期'),
+
+                // 包装完成数量 - 使用子查询
+                \think\Db::raw('(SELECT SUM(数量) FROM 设备_产量计酬 WHERE 订单编号 = g.订单编号 AND 工序名称 = "包装" AND Mod_rq IS NULL) as 已完成数量'),
+
+                // 生产组别 - 使用子查询
+                \think\Db::raw('(SELECT GROUP_CONCAT(DISTINCT SUBSTRING(sczl_jtbh, 3, 2) ORDER BY SUBSTRING(sczl_jtbh, 3, 2) SEPARATOR "、") 
                             FROM 设备_产量计酬 
                             WHERE 订单编号 = g.订单编号 
                             AND 工序名称 = "车缝" 
                             AND Mod_rq IS NULL) as 生产组别'),
-            \think\Db::raw('NULL as 辅料入库时间'),
-            \think\Db::raw('NULL as 台产'),
-            \think\Db::raw('NULL as 产前样批核'),
-            \think\Db::raw('NULL as 备注'),
-        ])
-        ->group('g.订单编号')
-        ->select();
-
-    if (empty($list)) {
-        $this->success('', []);
-    }
 
-    // 处理日期字段,去掉时分秒
-    $dateFields = ['下单日期', '货期', '面料入库时间', '辅料入库时间', '开裁日期', '上车位日期', '车位完成日期', '后道完成日期'];
-    
-    foreach ($list as &$item) {
-        foreach ($dateFields as $field) {
-            if (isset($item[$field]) && !empty($item[$field])) {
-                $item[$field] = date('Y-m-d', strtotime($item[$field]));
-            }
+                // 占位字段
+                \think\Db::raw('NULL as 辅料入库时间'),
+                \think\Db::raw('NULL as 台产'),
+                \think\Db::raw('NULL as 产前样批核'),
+                \think\Db::raw('NULL as 备注'),
+            ])
+            ->group('g.订单编号')
+            ->select();
+
+        if (empty($list)) {
+            $this->success('', []);
         }
-        if (empty($item['生产组别'])) {
-            $item['生产组别'] = '';
+
+        // 处理日期字段,去掉时分秒
+        $dateFields = ['下单日期', '货期', '面料入库时间', '辅料入库时间', '开裁日期', '上车位日期', '车位完成日期', '后道完成日期'];
+
+        foreach ($list as &$item) {
+            foreach ($dateFields as $field) {
+                if (isset($item[$field]) && !empty($item[$field])) {
+                    $item[$field] = date('Y-m-d', strtotime($item[$field]));
+                }
+            }
+            if (empty($item['生产组别'])) {
+                $item['生产组别'] = '';
+            }
+            // 确保数值字段为整数
+            $item['实裁数量'] = intval($item['实裁数量'] ?? 0);
+            $item['已完成数量'] = intval($item['已完成数量'] ?? 0);
+            $item['订单数量'] = intval($item['订单数量'] ?? 0);
+            $item['入库数量'] = intval($item['入库数量'] ?? 0);
         }
+
+        $this->success('成功', $list);
     }
 
-    $this->success('成功', $list);
-}
-   
 }
 

+ 0 - 145
application/api/controller/PieceWork.php

@@ -15,155 +15,10 @@ class PieceWork extends Api
 
     /**
      * 首页
-     *
      */
     public function index()
     {
         $this->success('请求成功');
     }
-    /**
-     * 获取单个计件定额
-     *
-     * @ApiMethod POST
-     * @params string code
-    */
-    public function getOnePieceWork(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        $code = $params['code'];
-        if (!isset($code)){
-            $this->error('参数不能为空');
-        }
-        $where['sys_bh'] = $code;
-        $field = 'rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc,rtrim(适用工序) as sygx,rtrim(适用机型) as syjx,
-                    日定额 as daily_quota,千件工价 as thousand_piece ,补产标准 as production_standard,机长比例 as fir_proportion,副机比例 as sec_proportion,
-                    调墨比例 as ink_proportion,二手比例 as second_hand_proportion,飞达比例 as feeder_proportion,辅助比例 as auxiliary_proportion,放卷比例 as unwinder_proportion,
-                    分切1比例 as cutting_one_proportion,分切2比例 as cutting_two_proportion,检验比例 as inspect_proportion';
-        $data = db('dic_lzde')->where($where)->field($field)->select();
-        $this->success('请求成功',$data);
-
-    }
-    /**
-     * 获取计件定额列表
-     *
-     * @ApiMethod GET
-     *
-    */
-    public function getPieceWork(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $field = 'Key_,Parent,rtrim(sys_bh) as sys_bh, rtrim(sys_mc) as sys_mc,rtrim(适用工序) as gx,rtrim(适用机型) as jx';
-        $list = db('dic_lzde')->field($field)->order('sys_bh')->select();
-        $data = [];
-        $machineData = [];
-        $handData = [];
-        foreach ($list as $key=>$value){
-            if (substr($value['sys_bh'],0,3) == '020' && $value['Parent'] == '1_'){//机器作业计件定额
-                $machineData[$key] = $value;
-            }
-            if (substr($value['sys_bh'],0,3) == '030' && $value['Parent'] == '196_'){//人工作业计件定额
-                $handData[$key] = $value;
-            }
-        }
 
-        //对机器作业计件定额的数组进行处理
-        $machineData = array_values($machineData);
-        foreach ($machineData as $k=>$v){
-            $child = db('dic_lzde')->where('Parent',$v['Key_'])->field($field)->select();
-            if (!empty($child)){
-                $machineData[$k]['child'] = $child;
-                foreach ($child as $i=>$j){
-                    if ($v['sys_mc'] == '检验车间'){ //找出检验车间机器下面的数据
-                        $children = db('dic_lzde')->where('Parent',$j['Key_'])->field($field)->select();
-                        $machineData[$k]['child'][$i]['children'] = $children;
-                    } else{
-                        $machineData[$k]['child'][$i]['children'] = [];
-                    }
-                }
-            }
-        }
-        $data['machineData'] = $machineData;
-        //对手工作业计件定额的数组进行处理
-        $handData = array_values($handData);
-        foreach ($handData as $k=>$v){
-            $child = db('dic_lzde')->where('Parent',$v['Key_'])->field($field)->select();
-            if (!empty($child)){
-                $handData[$k]['child'] = $child;
-                foreach ($child as $i=>$j){
-                    $children = db('dic_lzde')->where('Parent',$j['Key_'])->field($field)->select();
-                    if (!empty($children)){
-                        $handData[$k]['child'][$i]['children'] = $children;
-                    } else{
-                        $handData[$k]['child'][$i]['children'] = [];
-                    }
-                }
-            }else{
-                $handData[$k]['child'] = [];
-            }
-        }
-        $data['handData'] = $handData;
-        $this->success('请求成功',$data);
-
-
-    }
-    /**
-     * 获取日定额参数
-     * @ApiMethod POST
-     * @params string code
-     */
-    public function getPieceParams(){
-        if(!$this->request->isGet()){
-            $this->error('非法请求');
-        }
-        $req = $this->request->param();
-        if (!isset($req['code']) || empty($req['code'])){
-            $this->error('请求参数错误');
-        }
-        $where['sys_bh'] = array('like','%'.$req['code'].'%');
-        $field = 'rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc,rtrim(适用工序) as use_gx,rtrim(适用机型) as use_machine,日定额 as daily_quota,千件工价 as thousand_piece,
-        补产标准 as production_standard,UniqId';
-        $list = db('dic_lzde')->where($where)->field($field)->select();
-        $this->success('请求成功',$list);
-    }
-    /**
-     * 批量修改定额参数
-     * @ApiMethod POST
-     * @params object data
-    */
-    public function editAllParams(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        if (empty($params) || !isset($params[0]['UniqId'])){
-            $this->error('参数不能为空');
-        }
-        $i = 0;
-        foreach ($params as $key=>$value){
-            $data = [];
-            if (!empty($value['daily_quota'])){
-                $data['日定额'] = $value['daily_quota'];
-            }
-            if (!empty($value['thousand_piece'])){
-                $data['千件工价'] = $value['thousand_piece'];
-            }
-            if (!empty($value['production_standard'])){
-                $data['补产标准'] = $value['production_standard'];
-            }
-
-            $sql = db('dic_lzde')->where('UniqId',$value['UniqId'])->fetchSql(true)->update($data);
-            $res = Db::query($sql);
-            if ($res !== false){
-                $i++;
-            }
-        }
-        if ($i !== 0){
-            $this->success('更新成功');
-        }else{
-            $this->error('更新失败');
-        }
-    }
 }

+ 0 - 207
application/api/controller/Process.php

@@ -13,219 +13,12 @@ class Process extends Api
 {
     protected $noNeedLogin = ['*'];
     protected $noNeedRight = ['*'];
-
     /**
      * 首页
-     *
      */
     public function index()
     {
         $this->success('请求成功');
     }
-    /**
-     * 单个工序损耗接口
-     * @ApiMethod GET
-     * @params string code
-    */
-    public function getProcessLoss(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        $code = $params['code'];
-        if (!isset($code)){
-            $this->error('参数不能为空');
-        }
-        $where['sys_bh'] = $code;
-        $field = 'rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc,sys_rate0,sys_rate1,rtrim(适用机型) as remark';
-        $data = db('dic_lzsh')->where($where)->field($field)->select();
-        $this->success('请求成功',$data);
-    }
-    /**
-     * 获取工序损耗列表接口
-     * @ApiParams GET
-    */
-    public function getProcess(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $field = 'Key_,Parent,rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc';
-        $list = db('dic_lzsh')->field($field)->select();
-        $data = [];
-        $i = 0;
-        foreach ($list as $value){
-            if ($value['Parent'] == '0_'){
-                $data[$i] = $value;
-                //一级菜单
-                $data[$i]['child'] = db('dic_lzsh')->where('Parent',$value['Key_'])->field($field)->select();
-                foreach ($data[$i]['child'] as $k=>$v){
-                    $children = db('dic_lzsh')->where('Parent',$v['Key_'])->field($field)->select();
-                    //二级菜单
-                    $data[$i]['child'][$k]['children'] =  $children;
-                    if (!empty($children)){
-                        foreach ($children as $key=>$item){
-                            $childrens = db('dic_lzsh')->where('Parent',$item['Key_'])->field($field)->select();
-                            //三级菜单
-                            $data[$i]['child'][$k]['children'][$key]['childrens'] =  $childrens;
-                            if (!empty($childrens)){
-                                foreach ($childrens as $k1=>$v1){
-                                    $fiveChild = db('dic_lzsh')->where('Parent',$v1['Key_'])->field($field)->select();
-                                    $data[$i]['child'][$k]['children'][$key]['childrens'][$k1]['fiveChild'] =  $fiveChild;
-                                }
-                            }else{
-                                $data[$i]['child'][$k]['children'][$key]['childrens'] = [];
-                            }
-                        }
-                    }else{
-                        $data[$i]['child'][$k]['children']= [];
-                    }
-                }
-                $i++;
-            }
-        }
-        $this->success('请求成功',$data);
-    }
-    /**
-     * 获取工序损耗编码
-     * @ApiMethod GET
-     * @params string code
-     * @params string same_item
-     * @params string child_item
-    */
-    public function getProcessCode(){
-        if (Request::instance()->isGet() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->param();
-        if (!isset($params['code']) || !isset($params['same_item']) || !isset($params['child_item'])){
-            $this->error('参数错误');
-        }
-        $code = $params['code'];
-        if (empty($code)){//科目编码为空,表示需要增加一级科目
-           $res = db('dic_lzsh')->where('Parent','0_')->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
-           $num = (int)$res['sys_bh'] + 1;
-           $new_code = $num > 10 ? '0'.$num : '00'.$num;
-           $this->success('请求成功',$new_code);
-        }else{
-            if (($params['same_item'] == 0 && $params['child_item'] == 0) || ($params['same_item'] == 1 && $params['child_item'] == 1) ){
-                $this->error('参数错误');
-            }
-            $res = db('dic_lzsh')->where('sys_bh',$code)->find();
-            if ($params['same_item'] == 1){ //表示增加同级科目
-                $list = db('dic_lzsh')->where('Parent',$res['Parent'])->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
-                $num = (int)$list['sys_bh'] + 1;
-                $num = substr($num,-3);
-                $str = substr($code,0,-3);
-                $new_code = $str . $num;
-            }else{
-                $list = db('dic_lzsh')->where('Parent',$res['Key_'])->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
-                if (!empty($list)){
-                    $num = (int)$list['sys_bh'] + 1;
-                    $num = substr($num,-3);
-                    $new_code = $code . $num;
-                }else{
-                    $num = '001';
-                    $new_code = $code . $num;
-                }
-            }
-            $this->success('请求成功',$new_code);
-        }
-    }
-    /**
-     * 增加左侧科目
-     * @ApiMethod POST
-     * @params string code
-     * @params string name
-     * @params float  sys_rate0
-     * @params float  sys_rate1
-     * @params string  remark
-    */
-    public function add(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        if (empty($params) || !isset($params['code']) || !isset($params['name'])){
-            $this->error('参数不能为空');
-        }
-        $parentCode =  substr($params['code'],0,-3);
-        if (empty($parentCode)){
-            $parentCode = $params['code'];
-        }
-        $list = db('dic_lzsh')->where('sys_bh',$parentCode)->field('Key_')->find();
-        $uniqId = db('dic_lzsh')->order('UniqId desc')->value('UniqId');
-        $sql = "SELECT MAX(CAST(SUBSTRING(Key_, 1, LENGTH(Key_) - 1) AS UNSIGNED)) AS max_value FROM dic_lzsh";
-        $key = Db::query($sql);
-        $data = [];
-        $data['sys_bh'] = $params['code'];
-        $data['Parent'] = empty($list)? '0_':$list['Key_'];
-        $data['sys_mc'] = $params['name'];
-        $data['sys_rate0'] = $params['sys_rate0'];
-        $data['sys_rate1'] = $params['sys_rate1'];
-        $data['启用状态'] = 1;
-        $data['Key_'] = ($key[0]['max_value']+1).'_';
-        $data['UniqId'] = $uniqId+1;
-        if (!empty($params['remark'])){
-            $data['适用机型'] = $params['remark'];
-        }
-        $sql = db('dic_lzsh')->fetchSql(true)->insert($data);
-        $res = Db::query($sql);
-        if ($res !== false){
-            $this->success('新增成功');
-        }else{
-            $this->error('新增失败');
-        }
-    }
-    /**
-     * 修改左侧科目
-     * @params string code
-     * @params string name
-     * @params float  sys_rate0
-     * @params float  sys_rate1
-     * @params string  remark
-    */
-    public function edit(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        if (empty($params) || !isset($params['code']) || !isset($params['name'])){
-            $this->error('参数不能为空');
-        }
-        $data = [];
-        $data['sys_mc'] = $params['name'];
-        $data['sys_rate0'] = $params['sys_rate0'];
-        $data['sys_rate1'] = $params['sys_rate1'];
 
-        if (!empty($params['remark'])){
-            $data['适用机型'] = $params['remark'];
-        }
-        $sql = db('dic_lzsh')->where('sys_bh',$params['code'])->fetchSql(true)->update($data);
-        $res = Db::query($sql);
-        if ($res !== false){
-            $this->success('更新成功');
-        }else{
-            $this->error('更新失败');
-        }
-    }
-    /**
-     * 删除
-     * @ApiMethod POST
-     * @params string code
-    */
-    public function delete(){
-        if (Request::instance()->isPost() == false){
-            $this->error('非法请求');
-        }
-        $params = Request::instance()->post();
-        if (empty($params) || !isset($params['code'])){
-            $this->error('参数不能为空');
-        }
-        $res = db('dic_lzsh')->where('sys_bh',$params['code'])->delete();
-        if ($res !== false){
-            $this->success('删除成功');
-        }else{
-            $this->error('删除失败');
-        }
-    }
 }

+ 13 - 4
application/api/controller/WorkOrder.php

@@ -1964,15 +1964,27 @@ class WorkOrder extends Api
         }
         $where = ['a.BOM_工单编号' => $param['order']];
 
+        // 仅入库:按工单+物料名称汇总 number;多条入库时 rq 取最大(最后入库日)
+        $inboundSub = \db('库存_出入库明细')
+            ->where('name', '入库')
+            ->whereNull('Mod_rq')
+            ->field('order_id, 物料名称, SUM(`number`) as 入库数量, MAX(rq) as 实际入库时间')
+            ->group('order_id, 物料名称')
+            ->buildSql();
+
         $list = \db('工单_bom资料')
             ->alias('a')
             ->join('工单_基本资料 b', 'b.订单编号 = a.BOM_工单编号')
+            ->join([$inboundSub => 'c'], 'a.BOM_工单编号 = c.order_id AND a.BOM_物料名称 = c.物料名称', 'LEFT')
             ->field('a.BOM_工单编号 as 订单编号,b.生产款号 as 生产款号,b.客户编号 as 客户编号,b.款式 as 款式,
             a.BOM_物料名称 as 物料名称,a.BOM_投料单位 as 投料单位,a.BOM_计划用量 as 计划用料,a.BOM_标准用量 as 定额用料,
             a.计划入库时间,
             a.计划入库操作人,
+            b.审核日期 as 核批日期,
+            b.审核 as 核批人,
                 a.BOM_实际用量 as 裁床实际用料,a.BOM_desc as 备注,a.UNIQID,a.物料分类,
-            a.BOM_计划门幅 as 计划门幅, a.BOM_定额门幅 as 定额门幅,a.Sys_ID as ID,a.Sys_rq as 日期')
+            a.BOM_计划门幅 as 计划门幅, a.BOM_定额门幅 as 定额门幅,a.Sys_ID as ID,a.Sys_rq as 日期,
+            c.实际入库时间,c.入库数量')
             ->where($where)
             ->whereNull('a.Mod_rq')
             ->order('a.UNIQID desc')
@@ -2303,9 +2315,6 @@ class WorkOrder extends Api
             $this->error('请求错误');
         }
         $param = Request::instance()->post();
-echo "<pre>";
-print_r($param);
-echo "<pre>";die;
         if (empty($param)){$this->error('请求错误');}
         if(empty($param[0]['BOM_工单编号'])){$this->error('请求错误,请重新打开此页面');}