|
@@ -3411,29 +3411,59 @@ class Facility extends Api
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
$param = $this->request->param();
|
|
$param = $this->request->param();
|
|
|
- // $where = [
|
|
|
|
|
- // '类别' => '现场巡查记录'
|
|
|
|
|
- // ];
|
|
|
|
|
|
|
+ $where = [];
|
|
|
if (isset($param['machine'])){
|
|
if (isset($param['machine'])){
|
|
|
$where['设备编号'] = $param['machine'];
|
|
$where['设备编号'] = $param['machine'];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 添加最近一个月的时间条件
|
|
// 添加最近一个月的时间条件
|
|
|
$oneMonthAgo = date('Y-m-d H:i:s', strtotime('-1 month'));
|
|
$oneMonthAgo = date('Y-m-d H:i:s', strtotime('-1 month'));
|
|
|
$where['提交时间'] = ['>=', $oneMonthAgo];
|
|
$where['提交时间'] = ['>=', $oneMonthAgo];
|
|
|
-
|
|
|
|
|
- $field = '设备编号,提交时间';
|
|
|
|
|
- $data = db('制程检验_记录')->where($where)->field($field)->select();
|
|
|
|
|
- $result = [];
|
|
|
|
|
- foreach ($data as $key=>$value){
|
|
|
|
|
- $date = date('Y-m-d',strtotime($value['提交时间']));
|
|
|
|
|
- if (!isset($result[$value['设备编号']])){
|
|
|
|
|
- $result[$value['设备编号']] = [];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $rows = \db('制程检验_记录')->where($where)->field('设备编号,提交时间')->select();
|
|
|
|
|
+
|
|
|
|
|
+ // 机台 --> 使用部门 / 设备名称 映射
|
|
|
|
|
+ $machineInfo = [];
|
|
|
|
|
+ $machines = \db('设备_基本资料')
|
|
|
|
|
+ ->where('sys_sbID','<>','')
|
|
|
|
|
+ ->where('使用部门','<>','研发中心')
|
|
|
|
|
+ ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称,rtrim(使用部门) as 使用部门')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ foreach ($machines as $m) {
|
|
|
|
|
+ $machineInfo[$m['设备编号']] = $m;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 使用部门 => 机台 => 日期列表
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ foreach ($rows as $row) {
|
|
|
|
|
+ $machine = trim($row['设备编号']);
|
|
|
|
|
+ if ($machine === ''){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $info = isset($machineInfo[$machine]) ? $machineInfo[$machine] : null;
|
|
|
|
|
+ $department = $info ? $info['使用部门'] : '未分类';
|
|
|
|
|
+ if ($department === ''){
|
|
|
|
|
+ $department = '未分类';
|
|
|
}
|
|
}
|
|
|
- array_push($result[$value['设备编号']],$date);
|
|
|
|
|
|
|
+ $machineName = $info ? $info['设备名称'] : '';
|
|
|
|
|
+ $machineLabel = ($machineName === '' || $machineName === null) ? $machine : $machine . '-->' . $machineName;
|
|
|
|
|
+ $date = date('Y-m-d', strtotime($row['提交时间']));
|
|
|
|
|
+ $data[$department][$machineLabel][$date] = $date;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 日期去重后倒序,机台和部门按名称排序
|
|
|
|
|
+ ksort($data);
|
|
|
|
|
+ foreach ($data as $department => &$machineList) {
|
|
|
|
|
+ ksort($machineList);
|
|
|
|
|
+ foreach ($machineList as $label => &$dates) {
|
|
|
|
|
+ $dates = array_values($dates);
|
|
|
|
|
+ rsort($dates);
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($dates);
|
|
|
}
|
|
}
|
|
|
- ksort($result);
|
|
|
|
|
- $this->success('成功',$result);
|
|
|
|
|
|
|
+ unset($machineList);
|
|
|
|
|
+
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|