Explorar el Código

计件工计时单维护

su hace 1 año
padre
commit
3f78771e61

+ 155 - 3
application/api/controller/PieceWorkSchedule.php

@@ -32,7 +32,7 @@ class PieceWorkSchedule extends Api
         if(!$this->request->isGet()){
             $this->error('请求方式错误');
         }
-        $rows = db()->table('db_wgjs')
+        $rows = db()->table('db_wgjs1')
             ->field('LEFT(wgjs_rq, 7) as date')
             ->group('date')
             ->order('UniqId desc')
@@ -70,7 +70,7 @@ class PieceWorkSchedule extends Api
             $this->error('参数错误');
         }
 
-        $rows = db()->table('db_wgjs')
+        $rows = db()->table('db_wgjs1')
             ->field('LEFT(wgjs_rq, 10) as wgjs_rq, 
             wgjs_bh1, CAST(wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(wgjs_yy1) as wgjs_yy1, 
             wgjs_bh2, CAST(wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(wgjs_yy2) as wgjs_yy2, 
@@ -82,7 +82,7 @@ class PieceWorkSchedule extends Api
             ->order('wgjs_rq desc, UniqId asc')
             ->page($page,$limit)
             ->select();
-        $total = db()->table('db_wgjs')->where($where)->count();
+        $total = db()->table('db_wgjs1')->where($where)->count();
 
         $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名, 所在部门');
 
@@ -164,4 +164,156 @@ class PieceWorkSchedule extends Api
         }
         halt($params);
     }
+    /**
+     * 详情
+     * @ApiMethod (GET)
+     * @param string $wgjs_rq 日期
+     * @param string $wgjs_bh1 员工编号
+    */
+    public function detail(){
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }else{
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+        $rows = db()->table('db_wgjs1')
+        ->field('LEFT(wgjs_rq, 10) as wgjs_rq, 
+        wgjs_bh1, CAST(wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(wgjs_yy1) as wgjs_yy1, 
+        wgjs_bh2, CAST(wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(wgjs_yy2) as wgjs_yy2, 
+        wgjs_bh3, CAST(wgjs_js3 AS SIGNED) as wgjs_js3, rtrim(wgjs_yy3) as wgjs_yy3, 
+        wgjs_bh4, CAST(wgjs_js4 AS SIGNED) as wgjs_js4, rtrim(wgjs_yy4) as wgjs_yy4, 
+        wgjs_bh5, CAST(wgjs_js5 AS SIGNED) as wgjs_js5, rtrim(wgjs_yy5) as wgjs_yy5, 
+        wgjs_bh6, CAST(wgjs_js6 AS SIGNED) as wgjs_js6, rtrim(wgjs_yy6) as wgjs_yy6,
+        rs1.员工姓名 as name1,rs2.员工姓名 as name2,rs3.员工姓名 as name3,rs4.员工姓名
+        as name4,rs5.员工姓名 as name5,rs6.员工姓名 as name6,wgjs_冲定额1,wgjs_冲定额2
+        ,wgjs_冲定额3,wgjs_冲定额4,wgjs_冲定额5,wgjs_冲定额6')
+        ->join('人事_基本资料 rs1','rs1.员工编号=db_wgjs1.wgjs_bh1','LEFT')
+        ->join('人事_基本资料 rs2','rs2.员工编号=db_wgjs1.wgjs_bh2','LEFT')
+        ->join('人事_基本资料 rs3','rs3.员工编号=db_wgjs1.wgjs_bh3','LEFT')
+        ->join('人事_基本资料 rs4','rs4.员工编号=db_wgjs1.wgjs_bh4','LEFT')
+        ->join('人事_基本资料 rs5','rs5.员工编号=db_wgjs1.wgjs_bh5','LEFT')
+        ->join('人事_基本资料 rs6','rs6.员工编号=db_wgjs1.wgjs_bh6','LEFT')
+        ->where(['wgjs_rq'=>$req['wgjs_rq'].' 00:00:00','wgjs_bh1'=>$req['wgjs_bh1']])
+        ->find();
+        if($rows){
+        $this->success('成功',$rows);
+        }else{
+            $this->error('失败');
+        }   
+    }
+     /**
+     * 修改
+     * @ApiMethod POST
+    */
+    public function edit()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        // $req = ['wgjs_js1'=>12,'wgjs_rq'=>'2023-10-12','wgjs_bh1'=>'ZM01269'];
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['mod_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->update($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+      /**
+     * 新增
+     * @ApiMethod POST
+    */
+    public function add()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['sys_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->insert($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+    /**
+     * 删除
+     * @ApiMethod (GET)
+     * @param string $wgjs_rq 日期
+     * @param string $wgjs_bh1 员工编号
+    */
+    public function del(){
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }else{
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+        $rows = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'].' 00:00:00','wgjs_bh1'=>$req['wgjs_bh1']])
+        ->delete();
+        if($rows){
+        $this->success('成功');
+        }else{
+            $this->error('失败');
+        }   
+    }
 }

+ 110 - 9
application/api/controller/WorkOrderSpotCheck.php

@@ -31,14 +31,14 @@ class WorkOrderSpotCheck extends Api
         if(!$this->request->isGet()){
             $this->error('请求方式错误');
         }
-        $rows = db()->table('db_抽检记录')
+        $rows = db()->table('db_抽检记录1')
             ->field('LEFT(Sys_rq, 10) as date, COUNT(*) as counts')
             ->group('date')
             ->order('UniqId desc')
             ->limit(45)
             ->select();
 
-        $arr = db()->table('db_抽检记录')
+        $arr = db()->table('db_抽检记录1')
             ->field('LEFT(Sys_rq, 10) as date, rtrim(Sys_id) as Sys_id, COUNT(Sys_id) as count')
             ->where('Sys_rq','>=',$rows[44]['date'])
             ->group('date, Sys_id')
@@ -86,7 +86,7 @@ class WorkOrderSpotCheck extends Api
         }
         if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['Sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
 
-        $rows = db()->table('db_抽检记录')
+        $rows = db()->table('db_抽检记录1')
             ->field('LEFT(Sczl_rq, 10) as Sczl_rq, Sczl_bh, Sczl_gdbh, rtrim(Sczl_gxmc) as Sczl_gxmc,
             sczl_yjno, sczl_gxh, Sczl_num, Sczl_抽检数, sczl_A类废, sczl_B类废, sczl_C类废,
             rtrim(Sczl_desc) as Sczl_desc, rtrim(Sys_id) as Sys_id, Sys_rq, Mod_rq, UniqId')
@@ -95,7 +95,7 @@ class WorkOrderSpotCheck extends Api
             ->page($page,$limit)
             ->select();
 
-        $total = db()->table('db_抽检记录')->where($where)->count();
+        $total = db()->table('db_抽检记录1')->where($where)->count();
         $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
         $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
         foreach ($rows as $key=>$value) {
@@ -132,13 +132,114 @@ class WorkOrderSpotCheck extends Api
             $this->error('参数错误');
         }
 
-        $rows = db()->table('db_抽检记录')->alias('d')
-            ->field('d.*, ')
-            ->join('工单_基本资料 g', 'd.')
-            ->where('d.UniqId',$UniqId)
-            ->select();
+        $rows = db()->table('db_抽检记录1')
+        ->field('Sczl_bh,rs.员工姓名 as name,sczl_bzdh,LEFT(Sczl_rq, 10) as Sczl_rq,Sczl_gdbh,g.Gd_cpmc,
+        Sczl_gxmc,sczl_gxh,Sczl_num,Sczl_抽检数,Sczl_A类废,Sczl_B类废,Sczl_C类废,Sczl_desc')
+        ->join('人事_基本资料 rs','rs.员工编号=db_抽检记录1.Sczl_bh','LEFT')
+        ->join('工单_基本资料 g','g.Gd_gdbh=db_抽检记录1.Sczl_gdbh','LEFT')
+        ->where('db_抽检记录1.UniqId',$UniqId)->select();
 
 
         $this->success('成功',$rows);
     }
+    /**
+     * 修改
+     * @ApiMethod POST
+    */
+    public function edit()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['mod_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->update($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+      /**
+     * 新增
+     * @ApiMethod POST
+    */
+    public function add()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['sys_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->insert($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+   /**
+     * 删除
+     * @ApiMethod (GET)
+     * @param string $UniqId UniqId
+     */
+    public function del(){
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $rows = db()->table('db_抽检记录1')->where('UniqId',$UniqId)->delete();
+        if($rows){
+           $this->success('成功');
+        }else{
+           $this->error('失败');
+        }
+
+    }
 }