Ver código fonte

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

曹鹤洋 1 ano atrás
pai
commit
16c6f981c1

+ 243 - 0
application/api/controller/LargeWasteRewardPunish.php

@@ -3,6 +3,8 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
+use think\db;
+use think\Request;
 
 /**
  * 工序大废品惩奖记录接口
@@ -191,4 +193,245 @@ class LargeWasteRewardPunish extends Api
 
         $this->success('成功',$rows);
     }
+
+    /**
+     * 工单编号获取
+     * @return void
+     * @throws \think\exception\DbException
+     * @throws db\exception\DataNotFoundException
+     * @throws db\exception\ModelNotFoundException
+     */
+    public function JunkWorkOrderList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('非法请求');
+        }
+        $params = $this->request->param();
+        if (empty($params['search'])){
+            $this->error('参数错误');
+        }
+        $list = \db('工单_基本资料')
+            ->field('rtrim(Gd_gdbh) as 工单编号,rtrim(成品名称) as 产品名称')
+            ->where('Gd_gdbh','like','%'.$params['search'].'%')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到工单信息');
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 印件编号获取
+     * @return void
+     * @throws \think\exception\DbException
+     * @throws db\exception\DataNotFoundException
+     * @throws db\exception\ModelNotFoundException
+     */
+    public function PrintCodeList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('非法请求');
+        }
+        $param = $this->request->param();
+        if (empty($param['workorder'])){
+            $this->error('参数错误');
+        }
+        $list = \db('工单_印件资料')
+            ->field('rtrim(yj_Yjno) as 印件号,rtrim(yj_yjmc) as 印件名称')
+            ->where('Yj_Gdbh',$param['workorder'])
+            ->select();
+        if (empty($list)){
+            $this->success('未找到该工单印件');
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 工单工序获取
+     * @return void
+     * @throws \think\exception\DbException
+     * @throws db\exception\DataNotFoundException
+     * @throws db\exception\ModelNotFoundException
+     */
+    public function ProcessList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('非法请求');
+        }
+        $param = $this->request->param();
+        if (empty($param['workorder']) || empty($param['yjno'])){
+            $this->error('参数错误');
+        }
+        $list = \db('工单_工艺资料')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc')
+            ->where('Gy0_gdbh',$param['workorder'])
+            ->where('Gy0_yjno',$param['yjno'])
+            ->select();
+        if (empty($list)){
+            $this->success('未找到该工单工艺');
+        }
+        $data = [];
+        foreach ($list as $key=>$value){
+            if ((int)$value['gxh'] < 10){
+                $value['gxh'] = '0'.$value['gxh'];
+            }
+            $data[$key] = $value['gxh'].'-'.$value['gxmc'];
+        }
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 机台编号获取
+     * @return void
+     * @throws \think\exception\DbException
+     * @throws db\exception\DataNotFoundException
+     * @throws db\exception\ModelNotFoundException
+     */
+    public function MachineList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('非法请求');
+        }
+        $list = \db('设备_基本资料')
+            ->field('rtrim(设备编号) as 设备编号')
+            ->where('sys_sbID','<>','')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到机台编号');
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 机台班组获取
+     * @return void
+     * @throws \think\exception\DbException
+     * @throws db\exception\DataNotFoundException
+     * @throws db\exception\ModelNotFoundException
+     */
+    public function MachineClassList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('非法请求');
+        }
+        $param = $this->request->param();
+        if (empty($param['machine'])){
+            $this->error('参数错误');
+        }
+        $list = \db('设备_班组资料')
+            ->where('sczl_jtbh',$param['machine'])
+            ->field('rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,
+            rtrim(sczl_bh4) as bh4,rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,
+            rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
+            rtrim(sczl_bh10) as bh10,rtrim(sczl_bzdh) as 班组代号')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到该机台班组');
+        }
+        foreach ($list as $key=>$value){
+            for ($i=1;$i<=10;$i++){
+                if (!empty($value['bh'.$i])){
+                    $name = \db('人事_基本资料')->where('员工编号',$value['bh'.$i])->field('rtrim(员工姓名) as name')->find();
+                    if (isset($name['name'])){
+                        $list[$key]['组员'.$i] = [
+                            '编号' => $value['bh'.$i],
+                            '姓名' => $name['name']
+                        ];
+                    }
+                }else{
+                    $list[$key]['组员'.$i] = [
+                        '编号' => '',
+                        '姓名' => ''
+                    ];
+                }
+                unset($list[$key]['bh'.$i]);
+            }
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 大废品数据修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     * @throws db\exception\BindParamException
+     */
+    public function JunkDetailEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('非法请求');
+        }
+        $param = Request::instance()->post();
+        if (empty($param['sczl_gdbh']) || empty($param['UniqId'])){
+            $this->error('参数错误');
+        }
+        $param['mod_rq'] = date('Y-m-d H:i:s',time());
+        $data = $param;
+        unset($data['UniqId']);
+        $sql = \db('db_大废品')
+            ->where('UniqId',$param['UniqId'])
+            ->fetchSql(true)
+            ->update($data);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('修改成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 大废品数据添加
+     * @return void
+     * @throws \think\exception\PDOException
+     * @throws db\exception\BindParamException
+     */
+    public function JunkDetailAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('非法请求');
+        }
+        $param = Request::instance()->post();
+        if (empty($param['sczl_gdbh'])){
+            $this->error('参数错误');
+        }
+        $lastID = \db('db_大废品')->order('UniqId desc')->value('UniqId');
+        $param['sys_rq'] = date('Y-m-d H:i:s',time());
+        $param['mod_rq'] = '1900-01-01 00:00:00';
+        $param['UniqId'] = $lastID + 1;
+        $sql = \db('db_大废品')->fetchSql(true)->insert($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('添加成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 大废品数据删除
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function JunkDetailDel()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('非法请求');
+        }
+        $param = $this->request->param();
+        if (empty($param['UniqId'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$param['UniqId']);
+        $res = \db('db_大废品')
+            ->whereIn('UniqId',$idList)
+            ->delete();
+        if ($res !== false){
+            $this->success('删除成功');
+        }else{
+            $this->error('失败');
+        }
+    }
 }

+ 17 - 4
application/api/controller/StaffSalary.php

@@ -115,7 +115,11 @@ class StaffSalary extends Api
             //核算产量
             $accountingYield = $byThePieceYield + $afterProductionYield;
             //工时占比
-            $manHourRate = number_format($accountingYield / $value['日定额'],4);
+            if ($value['日定额'] > 0){
+                $manHourRate = number_format($accountingYield / $value['日定额'],4);
+            }else{
+                $manHourRate = '0.0000';
+            }
             for ($i=1; $i<11; $i++){
                 $bhKey = 'sczl_bh'.$i;
                 $xmKey = 'name'.$i;
@@ -179,7 +183,11 @@ class StaffSalary extends Api
             //核算产量
             $accountingYield = $byThePieceYield + $afterProductionYield;
             //工时占比
-            $manHourRate = number_format($accountingYield / $value['日定额'],4);
+            if ($value['日定额'] > 0){
+                $manHourRate = number_format($accountingYield / $value['日定额'],4);
+            }else{
+                $manHourRate = '0.0000';
+            }
             $item = [];
             $item['sczl_gdbh'] = $value['sczl_gdbh'];
             $item['sczl_yjno'] = $value['sczl_yjno'];
@@ -247,7 +255,11 @@ class StaffSalary extends Api
                     //核算产量
                     $value['核算产量'] = $value['计件产量'];
                     //工时占比
-                    $value['工时占比'] = round($value['计件产量']/$value['日定额'],4);
+                    if ($value['日定额'] > 0){
+                        $value['工时占比'] = round($value['计件产量']/$value['日定额'],4);
+                    }else{
+                        $value['工时占比'] = '0.0000';
+                    }
                     $item = [];
                     $item['sczl_gdbh'] = $value['sczl_gdbh'];
                     $item['sczl_yjno'] = $value['sczl_yjno'];
@@ -427,9 +439,10 @@ class StaffSalary extends Api
             $data[$key]['个人加班工资'] = number_format($overTimePay,2,'.', '');
             $data[$key]['UniqID'] = $UniqId++;
             $data[$key]['sys_ny'] = $params['date'];
+            $data[$key]['sys_rq'] = date('Y-m-d H:i:s');
+            $data[$key]['sys_id'] = $params['sys_id'];
             unset($data[$key]['核算产量']);
         }
-//        halt($data);
         $res = \db('绩效工资汇总')->insertAll($data);
         if ($res){
             $this->success('请求成功');