|
@@ -1 +1,222 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+namespace app\api\controller;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+use app\common\controller\Api;
|
|
|
|
|
+use think\Request;
|
|
|
|
|
+use function fast\e;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 财务管理-》成本参数管理
|
|
|
|
|
+ */
|
|
|
|
|
+class CostParameter extends Api
|
|
|
|
|
+{
|
|
|
|
|
+ protected $noNeedLogin = ['*'];
|
|
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 成本参数管理左侧菜单栏
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ public function GetTab()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = db('设备_基本资料')
|
|
|
|
|
+ ->where('sys_sbID','<>', '')
|
|
|
|
|
+ ->whereNotNull('sys_sbID')
|
|
|
|
|
+ ->group('使用部门')
|
|
|
|
|
+ ->column('rtrim(使用部门)');
|
|
|
|
|
+ $this->success('成功', $list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 成本参数管理机台列表
|
|
|
|
|
+ * @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('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [];
|
|
|
|
|
+ if (isset($param['sist']) && !empty($param['sist'])){
|
|
|
|
|
+ $where['使用部门'] = $param['sist'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $field = 'rtrim(使用部门) as 使用部门,设备编号,rtrim(设备名称) as 设备名称,原值,年折旧额,A_折旧月数 as 年折旧月数,A_月标准工时 as 月标准工时,
|
|
|
|
|
+ A_小时折旧额 as 小时折旧额,平均车速 as 最高限速,产能系数,sys_sbID as MES地址,通讯口,通道号,sys_id as 创建用户,sys_rq as 创建时间,mod_rq as 修改时间,UniqId';
|
|
|
|
|
+ $list = \db('设备_基本资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->whereNotNull('sys_sbID')
|
|
|
|
|
+ ->field($field)
|
|
|
|
|
+ ->order('设备编号')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ $this->success('成功', $list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 机台信息详情
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function MachineDetail()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param) || empty($param['UniqId'])){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $field = 'rtrim(使用部门) as 使用部门,设备编号,rtrim(设备名称) as 设备名称,原值,年折旧额,A_折旧月数 as 年折旧月数,A_月标准工时 as 月标准工时,
|
|
|
|
|
+ A_小时折旧额 as 小时折旧额,平均车速 as 最高限速,产能系数,rtrim(sys_sbID) as 关联地址,通讯端口,通道号,UniqId,rtrim(设备类别) as 设备等级,rtrim(供应商) as 供应商,
|
|
|
|
|
+ rtrim(出厂编号),安装日期,rtrim(财务编号) as 资产编号';
|
|
|
|
|
+ $list = \db('设备_基本资料')
|
|
|
|
|
+ ->where('UniqId', $param['UniqId'])
|
|
|
|
|
+ ->field($field)
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到数据');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->success('成功', $list);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设备信息修改
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function MachineUpdate()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = Request::instance()->post();
|
|
|
|
|
+ if (empty($param) || empty($param['UniqId'])){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ '设备名称' => $param['设备名称'],
|
|
|
|
|
+ '供应商' => $param['供应商'],
|
|
|
|
|
+ '出厂编号' => $param['出厂编号'],
|
|
|
|
|
+ '安装日期' => $param['安装日期'],
|
|
|
|
|
+ '财务编号' => $param['资产编号'],
|
|
|
|
|
+ '设备类别' => $param['设备等级'],
|
|
|
|
|
+ '原值' => $param['原值'],
|
|
|
|
|
+ '年折旧额' => $param['年折旧额'],
|
|
|
|
|
+ 'A_折旧月数' => $param['年折旧月数'],
|
|
|
|
|
+ 'A_月标准工时' => $param['月标准工时'],
|
|
|
|
|
+ 'A_小时折旧额' => $param['小时折旧额'],
|
|
|
|
|
+ '平均车速' => $param['最高限速'],
|
|
|
|
|
+ '产能系数' => $param['产能系数'],
|
|
|
|
|
+ 'sys_sbID' => $param['关联地址'],
|
|
|
|
|
+ '通讯口' => $param['通讯端口'],
|
|
|
|
|
+ '通道号' => $param['通道号'],
|
|
|
|
|
+ 'mod_rq' => date('Y-m-d H:i:s', time()),
|
|
|
|
|
+ ];
|
|
|
|
|
+ $sql = \db('设备_基本资料')
|
|
|
|
|
+ ->where('UniqId', $param['UniqId'])
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->update($data);
|
|
|
|
|
+ $res = db()->query($sql);
|
|
|
|
|
+ if ($res === false){
|
|
|
|
|
+ $this->error('修改失败');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->success('修改成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设备信息删除
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function MachineDelete()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param) || empty($param['UniqId'])){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $res = \db('设备_基本资料')
|
|
|
|
|
+ ->where('UniqId', $param['UniqId'])
|
|
|
|
|
+ ->delete();
|
|
|
|
|
+ if ($res === false){
|
|
|
|
|
+ $this->error('删除失败');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->success('删除成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设备信息新增
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function MachineAdd()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = Request::instance()->post();
|
|
|
|
|
+ if (empty($param) || empty($param['设备编号'])){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ '使用部门' => $param['使用部门'],
|
|
|
|
|
+ '设备编号' => $param['设备编号'],
|
|
|
|
|
+ '设备名称' => $param['设备名称'],
|
|
|
|
|
+ '供应商' => $param['供应商'],
|
|
|
|
|
+ '出厂编号' => $param['出厂编号'],
|
|
|
|
|
+ '安装日期' => $param['安装日期'],
|
|
|
|
|
+ '财务编号' => $param['资产编号'],
|
|
|
|
|
+ '设备类别' => $param['设备等级'],
|
|
|
|
|
+ '原值' => $param['原值'],
|
|
|
|
|
+ '年折旧额' => $param['年折旧额'],
|
|
|
|
|
+ 'A_折旧月数' => $param['年折旧月数'],
|
|
|
|
|
+ 'A_月标准工时' => $param['月标准工时'],
|
|
|
|
|
+ 'A_小时折旧额' => $param['小时折旧额'],
|
|
|
|
|
+ '平均车速' => $param['最高限速'],
|
|
|
|
|
+ '产能系数' => $param['产能系数'],
|
|
|
|
|
+ 'sys_sbID' => $param['关联地址'],
|
|
|
|
|
+ '通讯口' => $param['通讯端口'],
|
|
|
|
|
+ '通道号' => $param['通道号'],
|
|
|
|
|
+ 'sys_rq' => date('Y-m-d H:i:s', time()),
|
|
|
|
|
+ 'sys_id' => $param['sys_id'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $sql = db('设备_基本资料')
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->insert($data);
|
|
|
|
|
+ $res = db()->query($sql);
|
|
|
|
|
+ if ($res === false){
|
|
|
|
|
+ $this->error('添加失败');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->success('添加成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|