| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 首页接口
- */
- class Index extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 首页
- *
- */
- public function index()
- {
- $this->success('请求成功');
- }
- //计划/排程/制程工单数量同步Redis
- public function numDbToRedis()
- {
- $numDbToRedis = [];
- //获取计划中的订单数量
- $jhz = db('工单_基本资料')
- ->where('gd_statu','like','%计划中%')
- ->count('Gd_gdbh');
- if($jhz!==false){
- $numDbToRedis['jhz'] = $jhz;
- }else{
- $numDbToRedis['jhz'] = 0;
- }
- //获取生产中的所有数据
- $rows = db('工单_基本资料')
- ->distinct('Gd_gdbh')
- ->where('gd_statu','like','%生产中%')
- ->column('Gd_gdbh');
- if($rows===false){
- $numDbToRedis['pcz'] = 0;
- $numDbToRedis['zcz'] = 0;
- $bool = cache('numDbToRedis',$jhz);
- if($bool===false) $this->error('订单数量存入redis失败','','000001');
- $this->success('请求成功');
- }
- //查询Gy0_sj1不等于1900-01-01 00:00:00的数据
- $data = db('工单_印件资料')->alias('y')
- ->join('工单_工艺资料 g','y.Yj_Gdbh = g.Gy0_gdbh AND y.yj_Yjno = g.Gy0_yjno')
- ->where('g.Gy0_sj1','<>','1900-01-01 00:00:00')
- ->where('y.Yj_Gdbh','in',$rows)
- ->group('y.Yj_Gdbh')
- ->column('y.Yj_Gdbh');
- $zcz = count($data);
- $pcz = count($rows) - count($data);
- $numDbToRedis['pcz'] = $pcz;
- $numDbToRedis['zcz'] = $zcz;
- $bool = cache('numDbToRedis',$numDbToRedis);
- if($bool===false) $this->error('订单数量存入redis失败','','000002');
- $this->success('同步成功');
- }
- //获取计划中工单数量
- public function getJhzByRedis()
- {
- $row = cache('numDbToRedis');
- if($row){
- $data = [
- 'status'=>0,
- 'msg'=>'',
- 'data'=>[
- 'name'=>'',
- 'value'=>$row['jhz']
- ]
- ];
- return json($data);
- }else{
- $data = [
- 'status'=>0,
- 'msg'=>'失败',
- 'data'=>[
- 'name'=>'',
- 'value'=>''
- ]
- ];
- return json($data);
- }
- }
- //获取排程中工单数量
- public function getPczByRedis()
- {
- $row = cache('numDbToRedis');
- if($row){
- $data = [
- 'status'=>0,
- 'msg'=>'',
- 'data'=>[
- 'name'=>'',
- 'value'=>$row['pcz']
- ]
- ];
- return json($data);
- }else{
- $data = [
- 'status'=>0,
- 'msg'=>'失败',
- 'data'=>[
- 'name'=>'',
- 'value'=>''
- ]
- ];
- return json($data);
- }
- }
- //获取制程中工单数量
- public function getZczByRedis()
- {
- $row = cache('numDbToRedis');
- if($row){
- $data = [
- 'status'=>0,
- 'msg'=>'',
- 'data'=>[
- 'name'=>'',
- 'value'=>$row['zcz']
- ]
- ];
- return json($data);
- }else{
- $data = [
- 'status'=>0,
- 'msg'=>'失败',
- 'data'=>[
- 'name'=>'',
- 'value'=>''
- ]
- ];
- return json($data);
- }
- }
- //印刷车间生产进度数据同步Redis
- public function yscjDbToRedis()
- {
- $yscjDbToRedis = [];
- //获取所有印刷车间
- // $rows = db('设备_基本资料')
- // ->where('使用部门','凹丝印车间')
- // ->column('设备编号');
- $rows = db('设备_基本资料')
- ->whereIn('使用部门', ['凹丝印车间', '胶印车间'])
- ->column('设备编号');
- foreach($rows as $value){
- $row = db('设备_产量采集')->alias('c')
- ->field('c.设备编号 as 机台号,
- c.工单编号 as 在产工单号,
- j.Gd_cpmc as 工单名称,
- c.工序名称 as 工序,
- g.Gy0_计划接货数 as 计划产量,
- g.Gy0_小时产能 as 小时产能,
- c.当前状态 as 机台状态
- ')
- ->join('工单_工艺资料 g','c.设备编号 = g.Gy0_sbbh AND c.工单编号 = g.Gy0_gdbh AND c.印件号 = g.Gy0_yjno')
- ->join('工单_基本资料 j','j.Gd_gdbh = c.工单编号')
- ->where('c.设备编号',$value)
- ->order('c.UniqId desc')
- ->find();
- if(!$row) continue;
- $cl = db('设备_产量计酬')
- ->where(['sczl_gdbh'=>$row['在产工单号'], 'sczl_jtbh' => $row['机台号']])
- ->sum('sczl_cl');
- $row['已完成产量'] = $cl;
- array_push($yscjDbToRedis, $row);
- }
- $bool = cache('yscjDbToRedis',$yscjDbToRedis);
- if($bool===false) $this->error('存入redis失败','','000002');
- $this->success('同步成功');
- }
- //印后车间生产进度数据同步Redis
- public function yhcjDbToRedis()
- {
- $yhcjDbToRedis = [];
- //获取所有印后车间
- $rows = db('设备_基本资料')
- ->where('使用部门','印后车间')
- ->column('设备编号');
- foreach($rows as $value){
- $row = db('设备_产量采集')->alias('c')
- ->field('c.设备编号 as 机台号,
- c.工单编号 as 在产工单号,
- j.Gd_cpmc as 工单名称,
- c.工序名称 as 工序,
- g.Gy0_计划接货数 as 计划产量,
- g.Gy0_小时产能 as 小时产能,
- c.当前状态 as 机台状态
- ')
- ->join('工单_工艺资料 g','c.设备编号 = g.Gy0_sbbh AND c.工单编号 = g.Gy0_gdbh AND c.印件号 = g.Gy0_yjno')
- ->join('工单_基本资料 j','j.Gd_gdbh = c.工单编号')
- ->where('c.设备编号',$value)
- ->order('c.UniqId desc')
- ->find();
- if(!$row) continue;
- $cl = db('设备_产量计酬')
- ->where(['sczl_gdbh'=>$row['在产工单号'], 'sczl_jtbh' => $row['机台号']])
- ->sum('sczl_cl');
- $row['已完成产量'] = $cl;
- array_push($yhcjDbToRedis, $row);
- }
- $bool = cache('yhcjDbToRedis',$yhcjDbToRedis);
- if($bool===false) $this->error('存入redis失败','','000002');
- $this->success('同步成功');
- }
- //获取印刷车间生产进度数据
- public function getYscjByRedis()
- {
- $row = cache('yscjDbToRedis');
- if (empty($row)) {
- return json([
- 'status' => 0,
- 'msg' => '',
- 'data' => [] // 或者可以返回 []
- ]);
- }
- $result['columns'] = [
- ['name' => '机台号', 'id' => 'jtbh', 'width' => '11', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '在产工单号', 'id' => 'gdbh', 'width' => '15', 'textAlign' => 'left'],
- ['name' => '工单名称', 'id' => 'gdmc', 'width' => '35', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '工序', 'id' => 'gx', 'width' => '15', 'textAlign' => 'left'],
- ['name' => '计划产量', 'id' => 'jhcl', 'width' => '8', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '已完成产量', 'id' => 'wccl', 'width' => '9', 'autoWrap' => "true", 'textAlign' => 'center'],
- ['name' => '小时产能', 'id' => 'xscn', 'width' => '8', 'autoWrap' => "true", 'textAlign' => 'center'],
- ['name' => '机台状态', 'id' => 'status', 'width' => '8', 'autoWrap' => "true", 'textAlign' => 'center'],
- ];
- foreach ($row as $k => $v) {
- $result['rows'][$k] = [
- 'jtbh' => $v['机台号'],
- 'gdbh' => $v['在产工单号'],
- 'gdmc' => $v['工单名称'],
- 'gx' => $v['工序'],
- 'jhcl' => $v['计划产量'],
- 'wccl' => $v['已完成产量'],
- 'xscn' => $v['小时产能'],
- 'status' => $v['机台状态'],
- ];
- }
- return json([
- 'status' => 0,
- 'msg' => '',
- 'data' => $result
- ]);
- }
- //获取印后车间生产进度数据
- public function getYhcjByRedis()
- {
- $row = cache('yhcjDbToRedis');
- $result['columns']=[
- ['name'=>'机台号','id'=>'jtbh','width'=>'11','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'在产工单号','id'=>'gdbh','width'=>'15','textAlign'=>'left'],
- ['name'=>'工单名称','id'=>'gdmc','width'=>'35','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'工序','id'=>'gx','width'=>'15','textAlign'=>'left'],
- ['name'=>'计划产量','id'=>'jhcl','width'=>'8','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'已完成产量','id'=>'wccl','width'=>'9','autoWrap'=>"true",'textAlign'=>'center'],
- ['name'=>'小时产能','id'=>'xscn','width'=>'8','autoWrap'=>"true",'textAlign'=>'center'],
- ['name'=>'机台状态','id'=>'status','width'=>'8','autoWrap'=>"true",'textAlign'=>'center'],
- ];
- if($row){
- foreach($row as $k=>$v){
- $result['rows'][$k]['jtbh']=$v['机台号'];
- $result['rows'][$k]['gdbh']=$v['在产工单号'];
- $result['rows'][$k]['gdmc']=$v['工单名称'];
- $result['rows'][$k]['gx']=$v['工序'];
- $result['rows'][$k]['jhcl'] = $v['计划产量'];
- $result['rows'][$k]['wccl'] = $v['已完成产量'];
- $result['rows'][$k]['xscn'] = $v['小时产能'];
- $result['rows'][$k]['status'] = $v['机台状态'];
- }
- }
- $res['status']=0;
- $res['msg']='';
- $res['data']=$result;
- return json($res);
- }
- //车间产量数据同步Redis
- public function jtClDbToRedis()
- {
- $jtClDbToRedis = [];
- //获取机台
- $rows = db('设备_基本资料')
- ->whereNotNull('sys_sbID')
- ->column('设备编号');
- //获取24小时内的hour组成数组
- $hour = date('H');
- $arr1 = range($hour+1,'23');
- $arr2 = range('00',$hour);
- $arr = array_merge($arr1,$arr2);
- $arr = array_map(function($num) {
- return sprintf("%02d", $num);
- }, $arr);
- foreach($rows as $value){
- $brr = [];
- //查询该机台24内的产量数据
- $row = db('设备_产量计酬')
- ->where('sys_rq', '>', date('Y-m-d H:i:s', strtotime('-23 hours')))
- ->where('sczl_jtbh', $value)
- ->group('LEFT(sys_rq, 13)')
- ->order('sys_rq')
- ->column('DATE_FORMAT(sys_rq, "%H") as hour, SUM(sczl_cl) as total_cl');
- //将产量数据赋值给小时
- foreach($arr as $v){
- $brr[$v] = array_key_exists($v,$row) ? $row[$v] : '0';
- }
- $jtClDbToRedis[$value] = $brr;
- }
- $bool = cache('jtClDbToRedis',$jtClDbToRedis);
- if($bool===false) $this->error('存入redis失败','','000002');
- $this->success('同步成功');
- }
- //获取机台产量数据
- public function getJtClDbByRedis()
- {
- $req = $this->request->param();
- if (isset($req['jtbh']) && !empty($req['jtbh'])){
- $jtbh = $req['jtbh'];
- }else{
- $this->error('参数错误');
- }
- $row = cache('jtClDbToRedis');
- $result['categories']=[];
- $result['series'][0]['name']=$jtbh;
- $result['series'][0]['data']=[];
- if($row && array_key_exists($jtbh,$row)){
- $result['categories'] = array_map('strval', array_keys($row[$jtbh]));
- $result['series'][0]['data'] = array_values($row[$jtbh]);
- }
- $res['status']=0;
- $res['msg']='';
- $res['data']=$result;
- return json($res);
- }
- /**
- * 班组工作中心负荷
- */
- public function bzDbToRedis()
- {
- $bzDbToRedis = [];
- //计算当天时间
- $sczlTime = date('Y-m-d H:i:s',time());
- if ($sczlTime>date('Y-m-d 00:00:00') && $sczlTime<date('Y-m-d 08:30:00')){
- $time = date('Y-m-d 00:00:00',time()-86400);
- }else{
- $time = date('Y-m-d 00:00:00');
- }
- //获取所有机台数据
- $machineList = db('设备_基本资料')
- ->where('sys_sbID','<>','')
- ->where('使用部门','in',['印刷车间','印后车间'])
- ->field('设备编号')
- ->select();
- //循环获取班组、工单、生产数据
- foreach ($machineList as $key=>$value){
- //获取正在生产工单信息
- $workOrder = \db('设备_产量采集')
- ->where('设备编号',$value['设备编号'])
- ->field('工单编号,印件号,工序号,工序名称,当前状态')
- ->order('UniqId desc')
- ->find();
- if (!$workOrder) continue;
- //获取生产信息
- $list = db('设备_产量计酬')
- ->alias('a')
- ->join('工单_基本资料 b','b.Gd_gdbh = a.sczl_gdbh')
- ->join('工单_工艺资料 c','a.sczl_gdbh = c.Gy0_gdbh AND a.sczl_yjno = c.Gy0_yjno AND a.sczl_gxh = c.Gy0_gxh')
- ->field([
- 'SUM(a.sczl_cl)' => '已完成产量',
- 'b.成品名称' => '产品名称',
- 'c.Gy0_计划接货数' => '计划产量',
- 'c.Gy0_小时产能' => '小时产能',
- 'a.sczl_bzdh' => '班组代号'
- ])
- ->where([
- 'a.sczl_jtbh' => $value['设备编号'],
- 'a.sczl_gdbh' => $workOrder['工单编号'],
- 'a.sczl_yjno' => $workOrder['印件号'],
- 'a.sczl_gxh' => $workOrder['工序号'],
- 'a.sczl_rq' => $time
- ])
- ->group('a.sczl_jtbh,a.sczl_bzdh')
- ->select();
- if (!$list) continue;
- foreach ($list as $v){
- $v['机台号'] = $value['设备编号'];
- $v['机台状态'] = $workOrder['当前状态'];
- $v['工单编号'] = $workOrder['工单编号'];
- $v['印件号'] = $workOrder['印件号'];
- $v['工序名称'] = $workOrder['工序名称'];
- array_push($bzDbToRedis,$v);
- }
- }
- $bool = cache('bzDbToRedis',$bzDbToRedis);
- if($bool===false) $this->error('存入redis失败','','000002');
- $this->success('同步成功');
- }
- /**
- * 获取班组工作负荷数据
- */
- public function getBzByRedis()
- {
- $row = cache('bzDbToRedis');
- $result['columns']=[
- ['name'=>'机台号','id'=>'jtbh','width'=>'14','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'班组','id'=>'bzdh','width'=>'16','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'在产工单号','id'=>'gdbh','width'=>'16','textAlign'=>'left'],
- ['name'=>'工单名称','id'=>'gdmc','width'=>'20','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'印件号','id'=>'yjno','width'=>'16','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'工序','id'=>'gx','width'=>'16','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'计划产量','id'=>'jhcl','width'=>'14','autoWrap'=>"true",'textAlign'=>'left'],
- ['name'=>'已完成产量','id'=>'wccl','width'=>'14','autoWrap'=>"true",'textAlign'=>'center'],
- ['name'=>'小时产能','id'=>'xscn','width'=>'14','autoWrap'=>"true",'textAlign'=>'center'],
- ['name'=>'机台状态','id'=>'status','width'=>'14','autoWrap'=>"true",'textAlign'=>'center'],
- ];
- if($row){
- foreach($row as $k=>$v){
- $result['rows'][$k]['jtbh']=$v['机台号'];
- $result['rows'][$k]['bzdh']=$v['班组代号'];
- $result['rows'][$k]['gdbh']=$v['工单编号'];
- $result['rows'][$k]['gdmc']=$v['产品名称'];
- $result['rows'][$k]['yjno']=$v['机台号'];
- $result['rows'][$k]['gx']=$v['工序名称'];
- $result['rows'][$k]['jhcl'] = $v['计划产量'];
- $result['rows'][$k]['wccl'] = $v['已完成产量'];
- $result['rows'][$k]['xscn'] = $v['小时产能'];
- $result['rows'][$k]['status'] = $v['机台状态'];
- }
- }else{
- $result['rows'][0]['jtbh']='';
- $result['rows'][0]['bzdh']='';
- $result['rows'][0]['gdbh']='';
- $result['rows'][0]['gdmc']='';
- $result['rows'][0]['yjno']='';
- $result['rows'][0]['gx']='';
- $result['rows'][0]['jhcl'] = '';
- $result['rows'][0]['wccl'] = '';
- $result['rows'][0]['xscn'] = '';
- $result['rows'][0]['status'] = '';
- }
- $res['status']=0;
- $res['msg']='';
- $res['data']=$result;
- return json($res);
- }
- /**
- * 决策支持月度设备运行数据统计->班组(接口)
- */
- public function TeamsgGoups()
- {
- // 获取设备编组信息
- $result = \db('设备_基本资料')
- ->whereNotNull('设备编组')
- ->group('设备编组')
- ->column('rtrim(设备编组) as 设备编组');
- $data = [
- "columns" => [
- ["id" => "subsys"]
- ],
- "rows" => []
- ];
- foreach ($result as $value) {
- $data["rows"][] = ["subsys" => $value];
- }
- $res = [
- 'status' => 0,
- 'msg' => '',
- 'data' => $data
- ];
- return json($res);
- }
- /**
- * 决策支持月度设备运行数据统计->机台运行工时汇总(接口)
- */
- public function MonthlyEquipment() {
- // 获取请求参数,默认为 '01、切纸机组'
- $postData = input('post.dependence.item.subsys', '01、切纸机组');
- // 查询条件
- $where = [];
- if (!empty($postData)) {
- $where['设备编组'] = $postData;
- }
- // 获取当前年月
- $currentYearMonth = date('Y-m');
- // 获取去年的同月
- $lastYearMonth = date('Y-m', strtotime('-1 year'));
- // 查询 **今年** 当月的数据
- $currentData = \db('设备_基本资料')
- ->alias('a')
- ->join('设备_产量计酬 b', 'a.设备编号 = b.sczl_jtbh')
- ->field([
- 'a.设备编号' => '设备编号',
- 'SUM(b.sczl_cl)' => '产量'
- ])
- ->where($where)
- ->whereTime('b.sczl_rq', '>=', $currentYearMonth . '-01') // 查询当前月的第一天
- ->whereTime('b.sczl_rq', '<', date('Y-m-d', strtotime('next month', strtotime($currentYearMonth . '-01')))) // 下个月的第一天
- ->group('a.设备编号')
- ->order('a.设备编号')
- ->select();
- // 查询 **去年** 同月的数据
- $lastYearData = \db('设备_基本资料')
- ->alias('a')
- ->join('设备_产量计酬 b', 'a.设备编号 = b.sczl_jtbh')
- ->field([
- 'a.设备编号' => '设备编号',
- 'SUM(b.sczl_cl)' => '产量'
- ])
- ->where($where)
- ->whereTime('b.sczl_rq', '>=', $lastYearMonth . '-01') // 查询去年的同月第一天
- ->whereTime('b.sczl_rq', '<', date('Y-m-d', strtotime('next month', strtotime($lastYearMonth . '-01')))) // 下个月的第一天
- ->group('a.设备编号')
- ->order('a.设备编号')
- ->select();
- // 格式化数据
- $categories = [];
- $currentYearSeries = [];
- $lastYearSeries = [];
- // 转换查询结果为关联数组,方便查找
- $currentYearMap = [];
- $lastYearMap = [];
- foreach ($currentData as $item) {
- $currentYearMap[$item['设备编号']] = $item['产量'];
- }
- foreach ($lastYearData as $item) {
- $lastYearMap[$item['设备编号']] = $item['产量'];
- }
- // 统一设备编号,确保数据完整
- $allDevices = array_unique(array_merge(array_keys($currentYearMap), array_keys($lastYearMap)));
- foreach ($allDevices as $device) {
- $categories[] = $device;
- $currentYearSeries[] = isset($currentYearMap[$device]) ? intval($currentYearMap[$device]) : 0; // 今年产量
- $lastYearSeries[] = isset($lastYearMap[$device]) ? intval($lastYearMap[$device]) : 0; // 去年产量
- }
- // 组织返回数据
- $response = [
- 'status' => 0,
- 'msg' => '',
- 'data' => [
- 'categories' => $categories,
- 'series' => [
- [
- 'name' => '今年产量',
- 'data' => $currentYearSeries,
- 'type' => 'bar',
- 'yAxisIndex' => 0
- ],
- [
- 'name' => '去年产量',
- 'data' => $lastYearSeries,
- 'type' => 'bar',
- 'yAxisIndex' => 0
- ]
- ]
- ]
- ];
- return json($response);
- }
- /**
- * 决策支持月度设备运行数据统计->机台运行工时汇总列表(接口)
- */
- public function Equipmenttable(){
- // 获取请求数据
- $postData = input('post.dependence.item.subsys', '01、切纸机组');
- $where = [];
- if (!empty($postData)) {
- $where['设备编组'] = $postData;
- }
- // 获取当前月份
- $mouth = date_create_from_format('Ym', date('Ym'))->format('Y-m');
- // 查询设备数据
- $list = \db('设备_基本资料')->alias('a')
- ->join('设备_产量计酬 b', 'a.设备编号 = b.sczl_jtbh')
- ->field([
- 'a.设备编号' => '设备编号',
- 'rtrim(a.设备名称)' => '设备名称',
- 'SUM(b.sczl_cl)' => '产量',
- 'SUM(b.sczl_设备运行工时)' => '设备运行工时',
- 'SUM(b.sczl_保养工时)' => '保养工时',
- 'SUM(b.sczl_打样总工时)' => '打样总工时',
- 'SUM(b.sczl_打样工时)' => '打样补产工时',
- 'SUM(b.sczl_装版总工时)' => '装板总工时',
- 'SUM(b.sczl_装版工时)' => '装板补产工时',
- 'SUM(b.sczl_异常停机工时)' => '异常停机工时'
- ])
- ->where($where)
- ->whereTime('b.sczl_rq', $mouth)
- ->group('a.设备编号')
- ->order('a.设备编号')
- ->select();
- $rows = [];
- foreach ($list as $item) {
- $rows[] = [
- 'subsys' => $item['设备编号'],
- 'module' => $item['设备名称'],
- 'business' => $item['产量'],
- 'sbyxgs' => $item['设备运行工时'],
- 'dyzgs' => $item['打样总工时'],
- 'dybcgs' => $item['打样补产工时'],
- 'zbzgs' => $item['装板总工时'],
- 'zbbcgs' => $item['装板补产工时'],
- 'yctjgs' => $item['异常停机工时']
- ];
- }
- // 最终响应格式
- $response = [
- 'status' => 0,
- 'msg' => '',
- 'data' => [
- 'total' => count($rows),
- 'columns' => [
- ['name' => '设备编号','id' => 'subsys'],
- ['name' => '设备名称','id' => 'module'],
- ['name' => '产量','id' => 'business'],
- ['name' => '设备运行工时','id' => 'sbyxgs'],
- ['name' => '打样总工时','id' => 'dyzgs'],
- ['name' => '打样补产工时','id' => 'dybcgs'],
- ['name' => '装板总工时','id' => 'zbzgs'],
- ['name' => '装板补产工时','id' => 'zbbcgs'],
- ['name' => '异常停机工时','id' => 'yctjgs',]
- ],
- // 'superHeaders' => [
- // [
- // [
- // 'name' => '设备信息',
- // 'colspan' => 3
- // ],
- // [
- // 'name' => '工时统计',
- // 'colspan' => 2
- // ]
- // ]
- // ],
- 'rows' => $rows
- ]
- ];
- return json($response);
- }
- /**
- * 工序产出率月统计报表(接口)
- */
- public function Monthlystatistical(){
- }
- }
|