|
@@ -93,7 +93,7 @@ class Facility extends Api
|
|
|
//产品名称
|
|
//产品名称
|
|
|
$productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
|
|
$productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
|
|
|
//组员信息
|
|
//组员信息
|
|
|
- $list = \db('设备_产量计酬')->where($where)->field($field)->select();
|
|
|
|
|
|
|
+ $list = \db('设备_产量计酬')->where($where)->field($field)->cache(true,86400)->select();
|
|
|
$totalA = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
|
|
$totalA = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
|
|
|
$totalB = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
|
|
$totalB = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
@@ -148,63 +148,49 @@ class Facility extends Api
|
|
|
'设备编号' => $machine,
|
|
'设备编号' => $machine,
|
|
|
'开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
|
|
'开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
|
|
|
'类别' => ['in',['IPQC检验','机台检验']],
|
|
'类别' => ['in',['IPQC检验','机台检验']],
|
|
|
|
|
+ 'sys_rq' => ['>',date('Y-m-d 08:30:00',strtotime($date))]
|
|
|
];
|
|
];
|
|
|
- //检验项目筛选
|
|
|
|
|
- $itemA = \db('制程检验_记录')->where($where)->distinct(true)->cache(true,3600)->where('班组编号','A班')->column('rtrim(检验项目)');
|
|
|
|
|
- $itemB = \db('制程检验_记录')->where($where)->distinct(true)->cache(true,3600)->where('班组编号','B班')->column('rtrim(检验项目)');
|
|
|
|
|
- //检验时间
|
|
|
|
|
- $InspectionTime = \db('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
|
|
|
|
|
- foreach ($InspectionTime as $k=>$v){
|
|
|
|
|
- $InspectionTime[$k] = date('H:i',strtotime($v));
|
|
|
|
|
- }
|
|
|
|
|
- //检测记录详情
|
|
|
|
|
- $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
|
|
|
|
|
- $nameDetailA = \db('制程检验_记录')->cache(true,3600)->where($where)->field($field)->where('班组编号','A班')->find();
|
|
|
|
|
- $nameDetailB = \db('制程检验_记录')->cache(true,3600)->where($where)->field($field)->where('班组编号','B班')->find();
|
|
|
|
|
- $list = $data1 = $data2 = [];
|
|
|
|
|
- //A班检测数据
|
|
|
|
|
- foreach ($itemA as $key=>$value){
|
|
|
|
|
- $SubmissionTime = \db('制程检验_记录')->where($where)
|
|
|
|
|
- ->where('班组编号','A班')
|
|
|
|
|
- ->where('检验项目',$value)
|
|
|
|
|
- ->where('检验结果','合格')
|
|
|
|
|
- ->field('rtrim(提交时间) as 提交时间')
|
|
|
|
|
- ->select();
|
|
|
|
|
- $time = [];
|
|
|
|
|
- foreach ($SubmissionTime as $k=>$v){
|
|
|
|
|
- $time[$k] = date('H:i',strtotime($v['提交时间']));
|
|
|
|
|
- }
|
|
|
|
|
- $data1[$key] = [
|
|
|
|
|
- '工单编号' => $nameDetailA['工单编号'],
|
|
|
|
|
- '印件号' => $nameDetailA['印件号'],
|
|
|
|
|
- '工序名称' => $nameDetailA['工序名称'],
|
|
|
|
|
- '检验项目' => $value,
|
|
|
|
|
- 'inspectresult' => implode(',',$time),
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,提交时间,rtrim(检验项目) as 检验项目';
|
|
|
|
|
+ $list = \db('制程检验_记录')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field($field)
|
|
|
|
|
+ ->cache(true,86400)
|
|
|
|
|
+ ->order('提交时间 desc')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->success('未找到检验记录');
|
|
|
}
|
|
}
|
|
|
- //B班数据详情
|
|
|
|
|
- foreach ($itemB as $key=>$value){
|
|
|
|
|
- $SubmissionTime = \db('制程检验_记录')->where($where)
|
|
|
|
|
- ->where('班组编号','B班')
|
|
|
|
|
- ->where('检验项目',$value)
|
|
|
|
|
- ->where('检验结果','合格')
|
|
|
|
|
- ->field('rtrim(提交时间) as 提交时间')
|
|
|
|
|
- ->select();
|
|
|
|
|
- $time = [];
|
|
|
|
|
- foreach ($SubmissionTime as $k=>$v){
|
|
|
|
|
- $time[$k] = date('H:i',strtotime($v['提交时间']));
|
|
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ foreach ($list as $key=>$value)
|
|
|
|
|
+ {
|
|
|
|
|
+ $data['item'][$key] = $value['检验项目'];
|
|
|
|
|
+ $data['InspectionTime'][$key] = date('H:i',strtotime($value['提交时间']));
|
|
|
|
|
+ $data['工单编号'][$key] = $value['工单编号'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $data['item'] = array_unique($data['item']);
|
|
|
|
|
+ $data['InspectionTime'] = array_values(array_unique($data['InspectionTime']));
|
|
|
|
|
+ $data['工单编号'] = array_unique($data['工单编号']);
|
|
|
|
|
+ foreach ($data['工单编号'] as $key => $value){
|
|
|
|
|
+ foreach ($data['item'] as $k=>$v){
|
|
|
|
|
+ $time = '';
|
|
|
|
|
+ foreach ($list as $kk=>$vv){
|
|
|
|
|
+ if ($vv['工单编号'] === $value && $vv['检验项目'] === $v){
|
|
|
|
|
+ $time = $time.date('H:i',strtotime($vv['提交时间'])).',';
|
|
|
|
|
+
|
|
|
|
|
+ $data['row'][$key][$k] = [
|
|
|
|
|
+ '工单编号' => $value,
|
|
|
|
|
+ '印件号' => $vv['印件号'],
|
|
|
|
|
+ '工序名称' => $vv['工序名称'],
|
|
|
|
|
+ '检验项目' => $v,
|
|
|
|
|
+ 'time' => substr($time,0,-1),
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- $data2[$key] = [
|
|
|
|
|
- '工单编号' => $nameDetailB['工单编号'],
|
|
|
|
|
- '印件号' => $nameDetailB['印件号'],
|
|
|
|
|
- '工序名称' => $nameDetailB['工序名称'],
|
|
|
|
|
- '检验项目' => $value,
|
|
|
|
|
- 'inspectresult' => implode(',',$time),
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ $data['row'][$key] = array_values($data['row'][$key]);
|
|
|
}
|
|
}
|
|
|
- $list = array_merge($data2,$data1);
|
|
|
|
|
- $list['inspectiontime'] = $InspectionTime;
|
|
|
|
|
- $this->success('成功',$list);
|
|
|
|
|
|
|
+ unset($data['item'],$data['工单编号']);
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1090,17 +1076,17 @@ class Facility extends Api
|
|
|
}
|
|
}
|
|
|
$data = [];
|
|
$data = [];
|
|
|
//机台状态时间
|
|
//机台状态时间
|
|
|
-
|
|
|
|
|
$startTime = \db('设备_产量采集')
|
|
$startTime = \db('设备_产量采集')
|
|
|
->where('设备编号',$param['machine'])
|
|
->where('设备编号',$param['machine'])
|
|
|
->where('开工时间',$param['start'])
|
|
->where('开工时间',$param['start'])
|
|
|
- ->field('rtrim()')
|
|
|
|
|
|
|
+ ->field('rtrim(时间) as 时间,当班产量,rtrim(当前状态) as 状态,MAX(时间) as 最大时间,MAX(当班产量) as 最大产量')
|
|
|
->order('UniqId')
|
|
->order('UniqId')
|
|
|
|
|
+ ->group('当前状态')
|
|
|
->find();
|
|
->find();
|
|
|
- if (!empty($startTime) && !empty($endTime)){
|
|
|
|
|
- $timeDifference = ($startTime($endTime['时间'])-strtotime($startTime['时间']))/3600;
|
|
|
|
|
|
|
+ if (!empty($startTime)){
|
|
|
|
|
+ $timeDifference = round((strtotime($startTime['最大时间'])-strtotime($startTime['时间']))/3600,2);
|
|
|
$data['timeDifference'] = $timeDifference;
|
|
$data['timeDifference'] = $timeDifference;
|
|
|
- $data['field'] = $endTime['当班产量']-$startTime['当班产量'];
|
|
|
|
|
|
|
+ $data['field'] = $startTime['最大产量']-$startTime['当班产量'];
|
|
|
}else{
|
|
}else{
|
|
|
$data['timeDifference'] = 0;
|
|
$data['timeDifference'] = 0;
|
|
|
$data['field'] = 0;
|
|
$data['field'] = 0;
|
|
@@ -1109,7 +1095,7 @@ class Facility extends Api
|
|
|
$row = \db('设备_产量采集')
|
|
$row = \db('设备_产量采集')
|
|
|
->where('设备编号',$param['machine'])
|
|
->where('设备编号',$param['machine'])
|
|
|
->where('开工时间',$param['start'])
|
|
->where('开工时间',$param['start'])
|
|
|
- ->field('rtrim(时间) as 时间,rtrim(当前产量) as 产量,rtrim(当前状态) as 状态')
|
|
|
|
|
|
|
+ ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
|
|
|
->select();
|
|
->select();
|
|
|
if (empty($row)){
|
|
if (empty($row)){
|
|
|
$data['row'] = '';
|
|
$data['row'] = '';
|
|
@@ -1120,15 +1106,38 @@ class Facility extends Api
|
|
|
if ($key<2){
|
|
if ($key<2){
|
|
|
$data['row'][$key]['产能'] = 0;
|
|
$data['row'][$key]['产能'] = 0;
|
|
|
}else{
|
|
}else{
|
|
|
- $data['row'][$key]['产能'] = ($row[$key-1]['产能']-$row[$key-2]['产能'])*60;
|
|
|
|
|
|
|
+ $data['row'][$key]['产能'] = ($row[$key-1]['产量']-$row[$key-2]['产量'])*60;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//机台状态
|
|
//机台状态
|
|
|
- $status = end($row)['状态'];
|
|
|
|
|
|
|
+ $status = end($row);
|
|
|
if (empty($status['状态'])){
|
|
if (empty($status['状态'])){
|
|
|
$data['status'] = '待单';
|
|
$data['status'] = '待单';
|
|
|
}else{
|
|
}else{
|
|
|
$data['status'] = $status['状态'];
|
|
$data['status'] = $status['状态'];
|
|
|
}
|
|
}
|
|
|
|
|
+ //检验数据
|
|
|
|
|
+ $list = \db('制程检验_记录')
|
|
|
|
|
+ ->where('开工时间',$param['start'])
|
|
|
|
|
+ ->where('设备编号',$param['machine'])
|
|
|
|
|
+ ->where('sys_rq','>',$param['start'])
|
|
|
|
|
+ ->field('rtrim(类别) as 类别,提交时间')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ $data['首件'] = $data['自检'] = $data['IPQC'] = [];
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->success('未找到检验记录');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ if ($value['类别'] == '现场巡查记录'){
|
|
|
|
|
+ array_push($data['首件'],$value['提交时间']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($value['类别'] == '机台自检'){
|
|
|
|
|
+ array_push($data['自检'],$value['提交时间']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($value['类别'] == 'IPQC检验'){
|
|
|
|
|
+ array_push($data['IPQC'],$value['提交时间']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|