|
@@ -0,0 +1,104 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+namespace app\api\controller;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+use app\common\controller\Api;
|
|
|
|
|
+use think\Db;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 设备运行跟踪
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+class Facility extends Api
|
|
|
|
|
+{
|
|
|
|
|
+ protected $noNeedLogin = ['*'];
|
|
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 左侧菜单栏
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getTab()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ $department = Db::table('设备_基本资料')->distinct(true)->column('使用部门');
|
|
|
|
|
+ if (empty($department)){
|
|
|
|
|
+ $this->error('未获取到机台数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($department as $value){
|
|
|
|
|
+ if (rtrim($value) !== '研发中心'){
|
|
|
|
|
+ $machine = Db::table('设备_基本资料')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
|
|
|
|
|
+ foreach ($machine as $kk=>$vv){
|
|
|
|
|
+ if ($vv['设备编号'] !== 'ZH01#'){
|
|
|
|
|
+ $date = Db::table('设备_产量计酬')->where('sczl_jtbh',$vv['设备编号'])->distinct(true)->order('UniqId desc')->limit(40)->column('sczl_rq');
|
|
|
|
|
+ $data[rtrim($value)][$vv['设备编号'].'【'.$vv['设备名称'].'】'] = $date;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //当日上报产量
|
|
|
|
|
+ public function chanLiang()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $machine = input('machine');
|
|
|
|
|
+ $date = input('date');
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'sczl_jtbh' => $machine,
|
|
|
|
|
+ 'sczl_rq' => date('Y-m-d H:i:s',strtotime($date)),
|
|
|
|
|
+ ];
|
|
|
|
|
+ $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as num,rtrim(sczl_sj1) as sj1,
|
|
|
|
|
+ rtrim(sczl_sj2) as sj2,rtrim(sczl_cl) as 产量,rtrim(sczl_bzdh) as bzdh,rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,
|
|
|
|
|
+ rtrim(sczl_装版工时) as 装版工时,rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常总工时,rtrim(sczl_设备运行工时) as 通电工时,
|
|
|
|
|
+ rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度数,
|
|
|
|
|
+ rtrim(sys_id) as 用户,rtrim(mod_rq) as 更新时间,rtrim(sczl_异常工时1) as 异常补时,rtrim(sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
|
|
|
|
|
+ sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
|
|
|
|
|
+ sczl_rate8,sczl_rate9,sczl_rate10';
|
|
|
|
|
+ //机台信息
|
|
|
|
|
+ $machineDetail = Db::table('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
|
|
|
|
|
+ //工单编号
|
|
|
|
|
+ $Gd_gdbh = Db::table('设备_产量计酬')->where($where)->distinct(true)->column('sczl_gdbh');
|
|
|
|
|
+ //产品名称
|
|
|
|
|
+ $productName = Db::table('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
|
|
|
|
|
+ //组员信息
|
|
|
|
|
+ $list = Db::table('设备_产量计酬')->where($where)->field($field)->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到机台数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName[$value['工单编号']];
|
|
|
|
|
+ if ($value['yjno']<10){
|
|
|
|
|
+ $list[$key]['yjno'] = '0'.$value['yjno'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxmc'];
|
|
|
|
|
+ $list[$key]['备注'] = $value['bzdh'].'('.$value['num'].')'.date('H:i',strtotime($value['sj1'])).'<-->'.date('H:i',strtotime($value['sj2']));
|
|
|
|
|
+ $list[$key]['千件工价'] = $machineDetail['千件工价'];
|
|
|
|
|
+ $list[$key]['日定额'] = $machineDetail['日定额'];
|
|
|
|
|
+ for ($i=1;$i<11;$i++){
|
|
|
|
|
+ if (isset($value['sczl_bh'.$i])){
|
|
|
|
|
+ $name = Db::table('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
|
|
|
|
|
+ if (isset($name['name'])){
|
|
|
|
|
+ $list[$key]['组员'.$i] = $value['sczl_bh'.$i].$name['name'].'('.((float)$value['sczl_rate'.$i]*100).'%'.')';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($list[$key]['sczl_bh'.$i],$list[$key]['sczl_rate'.$i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($list[$key]['工序编号'],$list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['num'],$list[$key]['sj1'],$list[$key]['sj2'],$list[$key]['bzdh']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|