Przeglądaj źródła

新增字典接口

huangsanjia 1 rok temu
rodzic
commit
57611b9627

+ 129 - 0
application/api/controller/Dictionary.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use \think\Request;
+use \think\Db;
+/**
+ * 常用字典接口
+ */
+class Dictionary extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 首页
+     *
+     */
+    public function index()
+    {
+        $this->success('请求成功');
+    }
+    /**
+     * 获取其他常用字典
+     * @ApiMethod GET
+     *
+    */
+    public function getTab(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $list = Db::name('erp_常用字典')->order('编号 asc')->column('trim(名称) as name');
+
+        // 分割字符串并合并相同项
+        $resultArray = [];
+        foreach ($list as $item) {
+            $parts = explode('_', $item);
+            // 使用第一个部分作为一级键,第二个部分作为二级键
+            $firstKey = $parts[0];
+            $secondKey = $parts[1];
+            $thirdValue = $parts[2];
+
+            $resultArray[$firstKey][$secondKey][] = $thirdValue;
+        }
+        // 对废品分类下的数组进行升序排序
+        if (isset($resultArray['data']['废品分类'])) {
+            foreach ($resultArray['data']['废品分类'] as &$category) {
+                // 判断是关联数组(单凹等)还是索引数组(分切等)
+                if (is_array($category) && !empty($category) && is_array(current($category))) {
+                    foreach ($category as &$subCategory) {
+                        ksort($subCategory);
+                    }
+                } else {
+                    ksort($category);
+                }
+            }
+        }
+        $this->success('请求成功',$resultArray);
+    }
+    /**
+     * 常用字典维护界面列表
+     * @ApiParams GET
+     * @params string class
+     * @params string search
+    */
+    public function getEditList(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (empty($params['class'])){
+            $this->error('参数错误');
+        }
+        $where = [];
+        $where['分类'] = $params['class'];
+        if (!empty($params['search'])){
+            $where['名称'] = array('like','%'.$params['search'].'%');
+        }
+        $list = Db::name('erp_常用字典')->where($where)->order('次序 desc,UniqId asc')->select();
+        $this->success('请求成功',$list);
+
+    }
+    /**
+     * 常用字典维护修改
+     * @ApiMethod POST
+     * @params string UniqId
+    */
+    public function edit(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+
+        if (!isset($params) || !isset($params[0]['UniqID'])){
+            $this->error('参数不能为空');
+        }
+        $i = 0;
+        foreach ($params as $key=>$value){
+            $data = [];
+            if (!empty($value['编号'])){
+                $data['编号'] = $value['编号'];
+            }
+            if (!empty($value['名称'])){
+                $data['名称'] = $value['名称'];
+            }
+            if (!empty($value['状态'])){
+                $data['禁用状态'] = 1;
+            }else{
+                $data['禁用状态'] = 0;
+            }
+            if (!empty($value['次序'])){
+                $data['次序'] = $value['次序'];
+            }
+            $sql = Db::name('erp_常用字典')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
+
+            $res = Db::query($sql);
+            if ($res !== false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+
+}

+ 57 - 2
application/api/controller/OtherCountDocument.php

@@ -3,7 +3,8 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-
+use \think\Request;
+use \think\Db;
 /**
  * 其他计件单据维护接口
  */
@@ -78,6 +79,7 @@ class OtherCountDocument extends Api
      * @ApiMethod (GET)
      * @param string $date 时间
      * @param string $Sczl_bh1 员工编号
+     * @param string $order 工单编号
      */
     public function getList()
     {
@@ -95,10 +97,12 @@ class OtherCountDocument extends Api
         $where = [];
         if (isset($req['date']) && !empty($req['date'])){
             $where['Sczl_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
+        }
+        if (!empty($req['order']) && (!empty($req['date']) || !empty($req['Sczl_bh1']))){
             $this->error('参数错误');
         }
         if (isset($req['Sczl_bh1']) && !empty($req['Sczl_bh1'])) $where['Sczl_bh1'] = $req['Sczl_bh1'];
+        if (isset($req['order']) && !empty($req['order'])) $where['Sczl_gdbh'] = $req['order'];
 
         $rows = db()->table('db_拉料计件')
             ->field('rtrim(sczl_Type) as sczl_Type, LEFT(Sczl_rq, 10) as Sczl_rq, Sczl_bh1, sczl_gdbh, CAST(Sczl_cl AS SIGNED) as Sczl_cl,
@@ -107,6 +111,7 @@ class OtherCountDocument extends Api
             ->page($page,$limit)
             ->order('Sczl_rq asc, UniqId asc')
             ->select();
+
         $total = db()->table('db_拉料计件')->where($where)->count();
         $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
         $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
@@ -150,4 +155,54 @@ class OtherCountDocument extends Api
 
         $this->success('成功',$rows);
     }
+    /**
+     * 拉料计件产量维护修改
+     * @ApiMethod POST
+     * @params array data
+    */
+    public function edit(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (!isset($params) || !isset($params['UniqId'])){
+            $this->error('参数不能为空');
+        }
+        $uniqId = $params['UniqId'];
+        unset($params['UniqId']);
+        $sql = Db::name('db_拉料计件')->where('UniqId',$uniqId)->fetchSql(true)->update($params);
+        $res = Db::query($sql);
+        if ($res !== false){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 获取拉料计件产量维护其他信息
+     * @ApiMethod GET
+     * @params string Sczl_bh1
+     * @params string Sczl_gdbh
+     * @params string Sczl_dedh
+    */
+    public function getOtherInfo(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (empty($params['Sczl_bh1']) && empty($params['Sczl_gdbh']) && empty($params['Sczl_dedh']) ){
+            $this->error('参数错误');
+        }
+        $data = [];
+        if (!empty($params['Sczl_bh1'])){
+            $data = Db::name('人事_基本资料')->where('员工编号',$params['Sczl_bh1'])->field('rtrim(员工姓名) as name')->find();
+        }
+        if (!empty($params['Sczl_gdbh'])){
+            $data = Db::name('工单_基本资料')->where('Gd_gdbh',$params['Sczl_gdbh'])->field('rtrim(成品名称) as name')->find();
+        }
+        if (!empty($params['Sczl_dedh'])){
+            $data = Db::name('dic_lzde')->where('sys_bh',$params['Sczl_dedh'])->field('rtrim(sys_mc) as name')->find();
+        }
+        $this->success('请求成功',$data);
+    }
 }