|
@@ -90,32 +90,42 @@ class ReportingWork extends Api
|
|
|
if (empty($params['majorprocess'])) {
|
|
if (empty($params['majorprocess'])) {
|
|
|
$this->error('大工序不能为空');
|
|
$this->error('大工序不能为空');
|
|
|
}
|
|
}
|
|
|
- $data = [];
|
|
|
|
|
- if($params['majorprocess'] == '车缝'){
|
|
|
|
|
- //获取部件资料
|
|
|
|
|
- $data = db('工单_部件资料')
|
|
|
|
|
|
|
+ if ($params['majorprocess'] === '车缝') {
|
|
|
|
|
+ $data = db('工单_部件资料')
|
|
|
->where('work_order', $params['workorder'])
|
|
->where('work_order', $params['workorder'])
|
|
|
- ->where('del_rq', null)
|
|
|
|
|
|
|
+ ->whereNull('del_rq')
|
|
|
->where('status', 1)
|
|
->where('status', 1)
|
|
|
->field('part_code as 部件编号,part_name as 部件名称')
|
|
->field('part_code as 部件编号,part_name as 部件名称')
|
|
|
- ->order('part_code')
|
|
|
|
|
->select();
|
|
->select();
|
|
|
if (empty($data)) {
|
|
if (empty($data)) {
|
|
|
$this->error('未找到部件资料');
|
|
$this->error('未找到部件资料');
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ usort($data, function ($a, $b) {
|
|
|
|
|
+ return strnatcmp((string)$a['部件编号'], (string)$b['部件编号']);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
$data = db('工单_基础工艺资料')
|
|
$data = db('工单_基础工艺资料')
|
|
|
->where('work_order', $params['workorder'])
|
|
->where('work_order', $params['workorder'])
|
|
|
->where('big_process', $params['majorprocess'])
|
|
->where('big_process', $params['majorprocess'])
|
|
|
- ->where('del_rq', null)
|
|
|
|
|
|
|
+ ->whereNull('del_rq')
|
|
|
->where('status', 0)
|
|
->where('status', 0)
|
|
|
- ->field('process_code as 工艺编号,process_name as 工艺名称,standard_hour as 标准工时,
|
|
|
|
|
|
|
+ ->field('part_code,process_code as 工艺编号,process_name as 工艺名称,standard_hour as 标准工时,
|
|
|
standard_score as 标准工分,coefficient as 系数,remark as 备注')
|
|
standard_score as 标准工分,coefficient as 系数,remark as 备注')
|
|
|
- ->order('part_code,process_code')
|
|
|
|
|
->select();
|
|
->select();
|
|
|
if (empty($data)) {
|
|
if (empty($data)) {
|
|
|
$this->error('未找到工艺数据');
|
|
$this->error('未找到工艺数据');
|
|
|
}
|
|
}
|
|
|
|
|
+ usort($data, function ($a, $b) {
|
|
|
|
|
+ $partCmp = strnatcmp((string)$a['part_code'], (string)$b['part_code']);
|
|
|
|
|
+ if ($partCmp !== 0) {
|
|
|
|
|
+ return $partCmp;
|
|
|
|
|
+ }
|
|
|
|
|
+ return strnatcmp((string)$a['工艺编号'], (string)$b['工艺编号']);
|
|
|
|
|
+ });
|
|
|
|
|
+ foreach ($data as &$row) {
|
|
|
|
|
+ unset($row['part_code']);
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($row);
|
|
|
}
|
|
}
|
|
|
$this->success('成功', $data);
|
|
$this->success('成功', $data);
|
|
|
}
|
|
}
|