unknown пре 7 месеци
родитељ
комит
9f7030eab9
1 измењених фајлова са 137 додато и 18 уклоњено
  1. 137 18
      application/api/controller/CostAccounting.php

+ 137 - 18
application/api/controller/CostAccounting.php

@@ -147,7 +147,7 @@ class CostAccounting extends Api
             $sql = db('成本v23_各月人工')
             $sql = db('成本v23_各月人工')
                 ->where('UniqID', $value['UniqID'])
                 ->where('UniqID', $value['UniqID'])
                 ->fetchSql(true)
                 ->fetchSql(true)
-                ->update(['一线工资总额'=>$value['number']]);
+                ->update(['一线工资总额'=>$value['number'],'Mod_rq'=>date('Y-m-d H:i:s', time())]);
             $res = db()->query($sql);
             $res = db()->query($sql);
             if ($res === false) {
             if ($res === false) {
                 $i++;
                 $i++;
@@ -584,24 +584,81 @@ class CostAccounting extends Api
     }
     }
 
 
 
 
-    //创建各月水电气分摊
-//    public function UtilitiesAdd()
-//    {
-//        if ($this->request->isGet() === false) {
-//            $this->error('请求错误');
-//        }
-//        $param = $this->request->param();
-//        if (empty($param)) {
-//            $this->error('参数错误');
-//        }
-//
-//    }
+    /**
+     * 创建各月水电气分摊
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function UtilitiesAdd()
+    {
+        if ($this->request->isPost() === false) {
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)) {
+            $this->error('参数错误');
+        }
+        $data = [];
+        foreach ($param as $k => $v) {
+            $data[] = [
+                'Sys_ny' => $v['sys_ny'],
+                '部门名称' => $v['sist'],
+                '费用类型' => '分摊',
+                '科目名称' => $v['科目名称'],
+                '耗电量' => $v['耗电量'],
+                '单位电价' => $v['单位电价'],
+                '耗气量' => $v['耗气量'],
+                '单位气价' => $v['单位气价'],
+                'Sys_id' => $v['sys_id'],
+                'Sys_rq' => date('Y-m-d H:i:s', time())
+            ];
+        }
+        $result = db('成本_各月水电气')->where('Sys_ny', $data[0]['sys_ny'])->where('费用类型','分摊')->delete();
+        $sql = db('成本_各月水电气')->fetchSql(true)->insertAll($data);
+        $res = db()->query($sql);
+        if ($res !== false) {
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
 
 
-    //各月水电气列表
-//    public function UtilitiesList()
-//    {
-//
-//    }
+    /**
+     * 各月水电气分摊费用列表
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function UtilitiesList()
+    {
+        if($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)) {
+            $this->error('参数错误');
+        }
+
+        $list = db('成本_各月水电气')
+            ->field('rtrim(部门名称) as 部门名称,rtrim(科目名称) as 科目名称,耗电量,单位电价,耗气量,单位气价')
+            ->where('费用类型', '分摊')
+            ->where('Sys_ny', $param['month'])
+            ->group('部门名称,科目名称')
+            ->select();
+        if (empty($list)) {
+            $list = db('成本_各月水电气')
+                ->field('rtrim(部门名称) as 部门名称,rtrim(科目名称) as 科目名称')
+                ->where('费用类型', '分摊')
+                ->group('部门名称,科目名称')
+                ->select();
+        }
+        foreach ($list as $k => $v) {
+            $list[$k]['年月'] = $param['month'];
+        }
+        $this->success('成功', $list);
+    }
 
 
 
 
     /**
     /**
@@ -625,4 +682,66 @@ class CostAccounting extends Api
         }
         }
         $this->success('成功', $data);
         $this->success('成功', $data);
     }
     }
+
+    //计算每个车间色度数
+    private function CountSistChromaticity($month,$sist)
+    {
+        $data = db('成本v23_月度成本明细')
+            ->where('sys_ny', $month)
+            ->where('车间名称', $sist)
+            ->group('车间名称')
+            ->value('班组车头产量*sczl_ms as 色度数');
+        return $data;
+    }
+
+    //计算每个机台色度数
+    private function CountMachineChromatic($month,$sist)
+    {
+        $data = db('成本v23_月度成本明细')
+            ->where('sys_ny', $month)
+            ->where('车间名称', $sist)
+            ->group('sczl_jtbh')
+            ->value('班组车头产量*sczl_ms as 色度数');
+        return $data;
+    }
+
+    //水电气分摊费用下方明细列表
+//    public function shuidianqiMachineDetailList()
+//    {
+//        if ($this->request->isGet() === false) {
+//            $this->error('请求错误');
+//        }
+//        $param = $this->request->param();
+//        if (empty($param)) {
+//            $this->error('参数错误');
+//        }
+//        $sist = ['胶印车间','凹丝印车间','印后车间','检验车间'];
+//        if (strpos($param['sist'],'车间') === false) {
+//            $number = db('成本_各月水电气')
+//                ->where('Sys_ny', $param['month'])
+//                ->where('部门名称', $param['sist'])
+//                ->where('费用类型', '分摊')
+//                ->value('');
+//        }else{
+//            $machineList = db('设备_基本资料')
+//                ->where('使用部门', $param['sist'])
+//                ->where('sys_sbID', '<>', '')
+//                ->order('设备编号')
+//                ->column('设备编号');
+//        }
+//
+//    }
+
+    //其他待摊费用
+    public function PrepaidExpensesList()
+    {
+        if ($this->request->isGet() === false) {
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)) {
+            $this->error('参数错误');
+        }
+
+    }
 }
 }