瀏覽代碼

工单管理

qiuenguang 1 年之前
父節點
當前提交
2a298f5b07
共有 2 個文件被更改,包括 475 次插入0 次删除
  1. 224 0
      application/api/controller/Manufacture.php
  2. 251 0
      application/api/controller/WorkOrder.php

+ 224 - 0
application/api/controller/Manufacture.php

@@ -0,0 +1,224 @@
+<?php
+
+namespace app\api\controller;
+
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ *
+ * 生产排单管理
+ */
+class Manufacture extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 计划中工单
+     * @ApiMethod (GET)
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Project()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $where = [
+            'gd_statu' => '3-计划中',
+            '行号' => '1',
+        ];
+        $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,
+        rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
+        rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
+        rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
+        $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
+        if ($list){
+            foreach ($list as $key=>$value){
+//                $cateGory = Db::table('产品_基本资料')->where('产品编号',$value['产品代号'])->find();
+//                $list[$key]['产品类别'] = $cateGory['产品类别'];
+                $list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
+            }
+        }
+        return json(['code'=>1,'msg'=>'成功','total'=>count($list),'data'=>$list]);
+    }
+
+    /**
+     * 计划中工单->工艺资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh   工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function projectCraft()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Gy0_gdbh' => $Gd_gdbh
+        ];
+        $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(重点工序) as 重点工序,Gy0_yjno,Gy0_gxh,Gy0_gxmc,Add_gxmc,rtrim(工序备注) as 工序备注,
+        rtrim(Gy0_sbbh) as 机组,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,
+        rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(UniqId) as UNIQID';
+        $list = Db::table('工单_工艺资料')->where($where)->field($filed)->select();
+        if ($list){
+            foreach ($list as $key=>$value){
+                if ((int)$value['Gy0_yjno'] <10){
+                    $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
+                }
+                if ((int)$value['Gy0_gxh'] <10){
+                    $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
+                }
+                if (rtrim($value['Add_gxmc']) == ''){
+                    $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
+                }else{
+                    $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
+                }
+                unset($list[$key]['Gy0_yjno'],$list[$key]['Gy0_gxh'],$list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
+            }
+        }
+        return json(['code'=>1,'msg'=>'成功','total'=>count($list),'data'=>$list]);
+    }
+
+
+    /**
+     * 计划中工单->印件资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh   工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function projectPrint()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Yj_Gdbh' => $Gd_gdbh,
+        ];
+        $field = 'rtrim(Yj_Gdbh) as 工单编号,rtrim(yj_Yjno) as 印件号,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_yjmc) as 印件名称,
+        rtrim(yj_zzmc) as 纸张名称,rtrim(yj_tlgg) as 投料规格,rtrim(yj_成品数量) as 成品数量,rtrim(yj_实际投料) as 实际投料,
+        rtrim(yj_Dw) as  投料单位,rtrim(yj_平张投料) as 平张投料,rtrim(yj_ls) as 联数,rtrim(yj_ks) as 开数,rtrim(Sys_id) as 创建用户,
+        rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID';
+        $list = Db::table('工单_印件资料')->where($where)->field($field)->select();
+        if ($list){
+            foreach ($list as $key=>$value){
+                $list[$key]['成品数量'] = rtrim((float)$value['成品数量']);
+                $list[$key]['实际投料'] = rtrim((float)$value['实际投料']);
+            }
+        }
+        return json(['code'=>1,'msg'=>'成功','total'=>count($list),'data'=>$list]);
+    }
+
+    /**
+     * 排程中/制程中工单
+     */
+    public function Schedule(){
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $where = [
+            'gd_statu' => '2-生产中',
+            '行号' => 1
+        ];
+        $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(接单日期) as 接单日期,
+        rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(销售订单号) as 销售订单号,rtrim(Gd_客户代号) as 客户编号,
+        rtrim(Gd_客户名称) as 客户名称,rtrim(客户料号) as 客户料号,rtrim(Uniqid) as GDUID';
+        $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
+        return json(['code'=>1,'msg'=>'成功','data'=>$list]);
+    }
+
+    /**
+     * 排程中/制程中工单->工序列表
+     */
+    public function ScheduleProcess()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Gy0_gdbh' => $Gd_gdbh,
+        ];
+        $field = 'rtrim(Gy0_gdbh) as 工单编号,Gy0_yjno,Gy0_gxh,Gy0_gxmc,Add_gxmc,rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_小时产能) as 小时产能,
+        rtrim(工价系数) as 产能系数,rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,rtrim(Gy0_最早开工时间) as 最早开工时间,
+        rtrim(Gy0_sj1) as 计划开工时间,rtrim(Gy0_sj2) as 计划完工时间,rtrim(Gy0_班次安排) as 班次安排,rtrim(工序备注) as 排单备注,
+        rtrim(PD_WG) as 工序完工,rtrim(UniqId) as UNIQID';
+        $list = Db::table('工单_工艺资料')->where($where)->field($field)->select();
+        if (empty($list)){
+            $this->error('未找到工序');
+        }
+        foreach ($list as $key=>$value){
+            if ((int)$value['Gy0_yjno'] <10){
+                $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
+            }
+            if ((int)$value['Gy0_gxh'] <10){
+                $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
+            }
+            if (rtrim($value['Add_gxmc']) == ''){
+                $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
+            }else{
+                $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
+            }
+            unset($list[$key]['Gy0_yjno'],$list[$key]['Gy0_gxh'],$list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
+            $list[$key]['机组'] = $value['设备编号'];
+            $list[$key]['工序产量'] = Db::table('工单_基本资料')->where('Gd_gdbh',$list[$key]['工单编号'])->field('rtrim(计划投料) as 计划投料')->find();
+//            $end = Db::table('设备_产量计酬')->where('sczl_gdbh',$value['工单编号'])->where('sczl_jtbh',$value['设备编号'])
+//                ->field('SUM(sczl_cl)')->select();
+//            $list[$key]['已完成产量'] = $end;
+//            $list[$key]['剩余产量'] = (int)$list[$key]['工序产量']-(int)$list[$key]['已完成产量'];
+        }
+        return json(['data'=>$list]);
+    }
+    /**
+     * 排单页面左侧车间和机台菜单
+     * @ApiMethod (GET)
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function workbench()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $data = [];
+        $department = Db::table('设备_基本资料')->distinct(true)->column('使用部门');
+        if ($department){
+            foreach ($department as $value){
+                if (rtrim($value) !== '研发中心'){
+                    $benchClass = Db::table('设备_基本资料')->where('使用部门',$value)->distinct(true)->column('设备编组');
+                    foreach ($benchClass as $v){
+                        if (rtrim($v) !== ''){
+                            $machine = Db::table('设备_基本资料')->where('使用部门',$value)->where('设备编组',$v)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
+                            foreach ($machine as $kk=>$vv){
+                                $data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
+                            }
+                        }
+                    }
+                }
+            }
+            return json(['code'=>1,'msg'=>'成功','data'=>$data]);
+        }
+    }
+}

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

@@ -0,0 +1,251 @@
+<?php
+
+namespace app\api\controller;
+
+
+use app\common\controller\Api;
+use think\Db;
+
+/**
+ * 工单资料管理
+ */
+class WorkOrder extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 工单资料菜单列表
+     *
+     * @ApiMethod (GET)
+     * @return false|string
+     * @throws \think\Exception
+     */
+    public function DataList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        //客户列表
+        $ClientList = Db::table('erp_客户供应商')->where('类型','客户')->column('简称','编号');
+        //获取总计划中数量和总生产中数量
+        $productingAll = Db::table('工单_基本资料')->where('gd_statu','2-生产中')->count();
+        $progressAll = Db::table('工单_基本资料')->where('gd_statu','3-计划中')->count();
+        $data = [
+            'productingAll' => $productingAll,
+            'progressAll' => $progressAll
+        ];
+        //按客户编号查询生产中,计划中数量
+        foreach ($ClientList as $key=>$value){
+            $order = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->count();
+            if ($order !== 0){
+                $productIng = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where('gd_statu','2-生产中')->count();
+                $proGress = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where('gd_statu','3-计划中')->count();
+                $Detail = [
+                    'Gd_khdh' => rtrim($key),
+                    'Gd_khmc' => rtrim($value),
+                    'producting' => rtrim($productIng),
+                    'progress' => rtrim($proGress),
+                ];
+                array_push($data,$Detail);
+            }
+        }
+        return json_encode(['code'=>1,'msg'=>'成功','data'=>$data]);
+    }
+
+    /**
+     * 工单基本资料列表
+     * @ApiMethod (GET)
+     * @param string $limit 查询长度
+     * @param string $Gd_khdh 客户代号
+     * @param string $startTime 接单日期开始时间
+     * @param string $endTime  接单日期结束时间
+     * @return \think\response\Json
+     * @throws \think\exception\DbException
+     */
+    public function WorkList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $limit = input('limit');
+        $clientNumber = input('Gd_khdh');
+        $startTime = input('start');
+        $endTime = input('end');
+        $where = [
+            'Gd_khdh' => $clientNumber
+        ];
+        if (isset($startTime) && isset($endTime)){
+            $where['接单日期'] = ['between',[$startTime,$endTime]];
+        }
+        $list = Db::table('工单_基本资料')
+            ->where($where)
+            ->order('接单日期 desc')
+            ->paginate($limit);
+        //工单基本资料数据整理
+        $data = [];
+        foreach ($list->items() as $key=>$value){
+            $data[$key] = [
+                '工单编号' => rtrim($value['Gd_gdbh']),
+                '生产分类' => rtrim($value['Gd_生产分类']),
+                '销售订单号' => rtrim($value['销售订单号']),
+                '产品代号' => rtrim($value['Gd_cpdh']),
+                '产品名称' => rtrim($value['Gd_cpmc']),
+                '订单数量' => rtrim($value['订单数量']),
+                '单位' => rtrim($value['计量单位']),
+                '折合大箱' => rtrim((int)$value['投料大箱']),
+                '投料率' => rtrim($value['投料率']),
+                '平均合格率' => '',
+                '开单日期' => date('Y-m-d',strtotime(rtrim($value['接单日期']))),
+                '交货日期' => date('Y-m-d',strtotime(rtrim($value['交货日期']))),
+                '工单类型' => rtrim($value['Gd_lx']),
+                '工单状态' => rtrim($value['gd_statu']),
+                '当前生产工序' => '',
+                '产量提交时间' =>  '',
+                '建档用户' => rtrim($value['Sys_id']),
+                '建档时间' => rtrim($value['Sys_rq']),
+                '更新时间' => rtrim($value['Mod_rq']),
+            ];
+        }
+        return json(['total'=>$list->total(),'data'=>$data]);
+    }
+
+    /**
+     * 印件资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh  工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Printed()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $list = Db::table('工单_印件资料')->where('Yj_Gdbh',$Gd_gdbh)->select();
+        $data = [];
+        if ($list){
+            foreach ($list as $key=>$value){
+                $data[$key] = [
+                    '印件号' => rtrim($value['yj_Yjno']),
+                    '印件代号' => rtrim($value['yj_Yjdh']),
+                    '印件名称' => rtrim($value['yj_yjmc']),
+                    '纸张代号' => rtrim($value['yj_zzdh']),
+                    '纸张名称' => rtrim($value['yj_zzmc']),
+                    '投料规格' => rtrim($value['yj_tlgg']),
+                    '平张投料' => rtrim($value['yj_平张投料']),
+                    '开料规格' => rtrim($value['yj_klgg']),
+                    '开数*联数' => rtrim($value['yj_ks']).'*'.rtrim($value['yj_ls']),
+                    '建档用户' => rtrim($value['Sys_id']),
+                    '建档时间' => rtrim($value['Sys_rq']),
+                    '更新时间' => rtrim($value['Mod_rq']),
+                ];
+            }
+        }
+        return json(['code'=>1,'mag'=>'成功','total'=>count($data),'data'=>$data]);
+    }
+
+    /**
+     * 工艺资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh  工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Craft()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $list = Db::table('工单_工艺资料')
+            ->where('Gy0_gdbh',$Gd_gdbh)
+            ->select();
+        $Gd_cpdh = Db::table('工单_基本资料')->where('Gd_gdbh',$Gd_gdbh)->field('Gd_cpdh')->find();
+        $data = [];
+        if ($list){
+            foreach ($list as $key=>$value){
+                if ($value['Gy0_yjno']<10){
+                    $value['Gy0_yjno'] = '0'.$value['Gy0_yjno'];
+                }
+                if ($value['Gy0_gxh']<10){
+                    $value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
+                }
+                $where = [
+                    'Gy0_cpdh' => $Gd_cpdh['Gd_cpdh'],
+                    'Gy0_yjno' => $value['Gy0_yjno'],
+                    'Gy0_gxh' => $value['Gy0_gxh'],
+                ];
+                $product = Db::table('产品_工艺资料')->where($where)->field('工价系数,损耗系数')->find();
+                $data[$key] = [
+                    '重点工序' => rtrim($value['重点工序']),
+                    '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
+                    '备选工序' => '',
+                    '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
+                    '计划产量' => '',
+                    '基础损耗' => rtrim($value['Gy0_Rate0']),
+                    '损耗率' => rtrim($value['Gy0_Rate1']),
+                    '报废定额' => '',
+                    '允损比例' => '',
+                    '难度系数' => rtrim($product['工价系数']),
+                    '损耗系数' => rtrim($product['损耗系数']),
+                    '人工检_次品板' => (int)$value['人工检_次品板']=0?'':$value['人工检_次品板'],
+                    '人工检_废检' => (int)$value['人工检_废检']=0?'':$value['人工检_废检'],
+                    '机检_正品板' => (int)$value['机检_正品板']=0?'':$value['机检_正品板'],
+                    '机检_次品板' => (int)$value['机检_次品板']=0?'':$value['机检_次品板'],
+                    '机检_废检' => (int)$value['机检_废检']=0?'':$value['机检_废检'],
+                    '开数*联数' => rtrim($value['Gy0_ks']).'*'.rtrim($value['Gy0_ls']),
+                    '备注' => rtrim($value['工序备注']),
+                    '印刷方式' => rtrim($value['印刷方式']),
+                    '版距' => rtrim($value['版距']),
+                    '建档用户' => rtrim($value['Sys_id']),
+                    '建档日期' => rtrim($value['Sys_rq']),
+                    '更新时间' => rtrim($value['Mod_rq']),
+                ];
+            }
+        }
+        return json(['code'=>1,'msg'=>'成功','total'=>count($data),'data'=>$data]);
+    }
+
+    /**
+     * BOM资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh   工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Bom(){
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $field = 'rtrim(BOM_方案) as 方案,rtrim(BOM_物料编码) as 物料编号,rtrim(BOM_物料名称) as 物料名称,BOM_投料单位,
+        BOM_投入数,BOM_产出数,BOM_产出单位,rtrim(BOM_计划用量) as 计划用量,rtrim(Sys_ID) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
+        $list = Db::table('工单_bom资料')
+            ->where('BOM_工单编号',$Gd_gdbh)
+            ->field($field)
+            ->select();
+        foreach ($list as $key=>$value){
+            $list[$key]['消耗定量'] = rtrim($value['BOM_投入数']).rtrim($value['BOM_投料单位']).'/'.rtrim($value['BOM_产出数']).rtrim($value['BOM_产出单位']);
+            unset($list[$key]['BOM_投料单位'],$list[$key]['BOM_投入数'],$list[$key]['BOM_产出数'],$list[$key]['BOM_产出单位']);
+            $list[$key]['计划用量'] = rtrim((float)$value['计划用量']);
+        }
+        return json(['code'=>1,'msg'=>'成功','total'=>count($list),'data'=>$list]);
+    }
+}