Kaynağa Gözat

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

曹鹤洋 1 yıl önce
ebeveyn
işleme
b98435ec96

+ 33 - 13
application/api/controller/Product.php

@@ -318,28 +318,48 @@ class Product extends Api
             if (empty($gyList)){
                 $this->error('参考产品无工艺资料数据');
             }
+            $UniqID = Db::name('产品_工艺资料')->order('UniqID desc')->value('UniqID');
             foreach ($gyList as $key=>$value){
                 unset($gyList[$key]['UniqID']);
+                $UniqID ++;
                 $gyList[$key]['Gy0_方案'] = $params['to_pro'];
                 $gyList[$key]['Gy0_cpdh'] = $params['to_code'];
+                $gyList[$key]['UniqID'] = $UniqID;
             }
+        }
+        if ($params['is_copy_yb'] == 1){
+            $UniqId = Db::name('产品_印版资料')->order('UniqID desc')->value('UniqID');
+            $option['YB_Cpdh'] = $params['from_code'];
+            $ybList = Db::name('产品_印版资料')->where($option)->select();
+            if (empty($ybList)){
+                $this->error('参考产品无印版资料数据');
+            }
+            foreach ($ybList as $key=>$value){
+                unset($ybList[$key]['UniqID']);
+                $UniqId++;
+                $ybList[$key]['YB_Cpdh'] = $params['to_code'];
+                $ybList[$key]['UniqID'] = $UniqId;
+            }
+        }
+        if ($params['is_copy_gy'] == 1 && $params['is_copy_yb'] == 1){
             $gyResult = Db::name('产品_工艺资料')->insertAll($gyList);
             if (!$gyResult){
                 $this->error('复制产品工艺资料数据失败');
             }
-        }
-        $option['YB_Cpdh'] = $params['from_code'];
-        $ybList = Db::name('产品_印版资料')->where($option)->select();
-        if (empty($ybList)){
-            $this->error('参考产品无印版资料数据');
-        }
-        foreach ($ybList as $key=>$value){
-            unset($ybList[$key]['UniqID']);
-            $ybList[$key]['YB_Cpdh'] = $params['to_code'];
-        }
-        $ybResult = Db::name('产品_印版资料')->insertAll($ybList);
-        if (!$ybResult){
-            $this->error('复制产品工艺资料数据失败');
+            $ybResult = Db::name('产品_印版资料')->insertAll($ybList);
+            if (!$ybResult){
+                $this->error('复制产品印版资料数据失败');
+            }
+        }elseif ($params['is_copy_gy'] == 1 && $params['is_copy_yb'] == 0){
+            $gyResult = Db::name('产品_工艺资料')->insertAll($gyList);
+            if (!$gyResult){
+                $this->error('复制产品工艺资料数据失败');
+            }
+        }else{
+            $ybResult = Db::name('产品_印版资料')->insertAll($ybList);
+            if (!$ybResult){
+                $this->error('复制产品印版资料数据失败');
+            }
         }
         $this->success('工艺复制成功');
     }

+ 17 - 6
application/api/controller/Staff.php

@@ -38,9 +38,6 @@ class Staff extends Api
         }
         $params = Request::instance()->param();
         $where = [];
-        if (!empty($params['department_code'])){
-            $where['部门编码']  = $params['department_code'];
-        }
         $where['在职状态'] = '在职';
         if (isset($params['mes_online'])){
             $where['在职状态'] = $params['mes_online'] > 1 ? '离职':'在职';
@@ -49,7 +46,6 @@ class Staff extends Api
         if (isset($params['u8_online'])){
             $where['U8在职'] = $params['u8_online'] > 1 ? '离职':'在职';
         }
-
         $where['员工编号|员工姓名'] = array('like','%'.$params['search'].'%');
         $limit = $params['limit'];
         if (empty($limit)){
@@ -59,10 +55,16 @@ class Staff extends Api
         if (empty($pages)){
             $pages = 1;
         }
+
         $field = '员工编号,rtrim(员工姓名) as 员工姓名,性别,聘用日期,转正日期,rtrim(所在部门) as 所在部门,rtrim(部门编码) as 部门编码,rtrim(职称职务) as 职称职务,rtrim(身份证号) as 身份证号,出生日期,
         rtrim(人员性质) as 人员性质,rtrim(人员类别) as 人员类别,班次类型,工资表类别,薪酬核算分组,rtrim(在职状态) as 在职状态,rtrim(U8在职) as U8在职,U8离职日期,rtrim(sys_id) as sys_id,sys_rq,mod_rq';
-        $list = Db::name('人事_基本资料')->where($where)->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
-        $total = Db::name('人事_基本资料')->where($where)->count();
+        if (strlen($params['department_code']) > 1){
+            $list = Db::name('人事_基本资料')->where($where)->where('部门编码',$params['department_code'])->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
+            $total = Db::name('人事_基本资料')->where($where)->where('部门编码',$params['department_code'])->count();
+        }else{
+            $list = Db::name('人事_基本资料')->where($where)->where('LEFT(部门编码,1)='.$params['department_code'])->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
+            $total = Db::name('人事_基本资料')->where($where)->where('LEFT(部门编码,1)='.$params['department_code'])->count();
+        }
         $data['list'] = $list;
         $data['total'] = $total;
         $this->success('请求成功',$data);
@@ -95,6 +97,15 @@ class Staff extends Api
                 $list[$key] = $value;
             }
         }
+        $six = Db::name('人事_基本资料')->where('在职状态','在职')->where('U8在职','离职')->count();
+        $sixArr['编号'] = '';
+        $sixArr['名称'] = '离职工资结算中';
+        $sixArr['total'] = $six;
+        $sev = Db::name('人事_基本资料')->where('在职状态','离职')->where('U8在职','离职')->count();
+        $sevArr['编号'] = '';
+        $sevArr['名称'] = '离职清单';
+        $sevArr['total'] = $sev;
+        array_push($data,$sixArr,$sevArr);
         foreach ($data as $k=>$v){
             $i = 0;
             $data[$k]['children'] = [];

+ 46 - 16
application/api/controller/WorkOrder.php

@@ -125,6 +125,12 @@ class WorkOrder extends Api
                 '更新时间' => rtrim($value['Mod_rq']),
                 'Uniqid' => rtrim($value['Uniqid'])
             ];
+            $number = Db::table('工单_工艺资料')->where('Gy0_gdbh',$data[$key]['工单编号'])->count();
+            if ($number === 0){
+                $data[$key]['status'] = '*';
+            }else{
+                $data[$key]['status'] = '';
+            }
         }
         $this->success('成功',$data);
     }
@@ -252,7 +258,10 @@ class WorkOrder extends Api
                     '质量隐患' => rtrim($value['质量隐患']),
                     '开数' => rtrim($value['Gy0_ks']),
                     '联数' => rtrim($value['Gy0_ls']),
-                    'UniqId' => rtrim($value['UniqId'])
+                    'UniqId' => rtrim($value['UniqId']),
+                    'shbh' => rtrim($value['Gy0_shbh']),
+                    '辅助工时' => rtrim($value['Gy0_辅助工时']),
+                    '小时产能' => rtrim($value['Gy0_小时产能'])
                 ];
             }
         }
@@ -952,32 +961,23 @@ class WorkOrder extends Api
         }
         $rate = Db::table('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
         $data = [
-            'Gy0_yjno' => isset($param['yjno'])?$param['yjno']:'',
-            'Gy0_gxh' => isset($param['gxh'])?$param['gxh']:'',
             '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
-            'Gy0_ks' => isset($param['ks'])?$param['ks']:'',
-            'Gy0_ls' => isset($param['ls'])?$param['ls']:'',
-            'Gy0_SITE' => isset($param['site'])?$param['site']:'',
-            'Gy0_gxmc' => isset($param['gxmc'])?$param['gxmc']:'',
-            'Add_gxmc' => isset($param['add_gxmc'])?$param['add_gxmc']:'',
-            'Gy0_ms' => isset($param['ms'])?$param['ms']:'',
+            '备选工序' => isset($param['bxgx'])?$param['bxgx']:'',
             'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
             'Gy0_Rate0' => $rate['rate0'],
             'Gy0_Rate1' => $rate['rate1'],
-            'Gy0_辅助工时' => isset($param['fzgs'])?$param['fzgs']:'',
-            'Gy0_小时产能' => isset($param['xscn'])?$param['xscn']:'',
             'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
             '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
             '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
-            '印刷方式' => isset($param['ysfs'])?$param['ysfs']:'',
-            '版距' => isset($param['bj'])?$param['bj']:'',
-            '工序备注' => isset($param['gxbz'])?$param['gxbz']:'',
-            '质量要求' => isset($param['zlyq'])?$param['zlyq']:'',
-            '质量隐患' => isset($param['sbyh'])?$param['sbyh']:'',
             'Mod_rq' => date('Y-m-d H:i:s',time()),
         ];
         $sql = Db::table('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
         $res = Db::query($sql);
+        $status = Db::table('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
+        if ($status['status'] !== '2-生产中'){
+            $statusSql = Db::table('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
+            Db::query($statusSql);
+        }
         if ($res !== false){
             $this->success('成功');
         }else{
@@ -985,6 +985,36 @@ class WorkOrder extends Api
         }
     }
 
+    /**
+     * 工艺资料编辑->机台列表获取
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function MachineList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = Db::table('设备_基本资料')
+            ->where('存放地点',$param['address'])
+            ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
+            ->select();
+        if (empty($list)){
+            $this->error('未找到该车间机台');
+        }
+        $data = [];
+        foreach ($list as $key=>$value){
+            $data[$key] = $value['设备编号'].'-->'.$value['设备名称'];
+        }
+        $this->success('成功',$data);
+    }
+
     /**
      * 打印作业通知单
      * @ApiMethod (POST)