'; // print_r($bottombar_rows); // echo ''; // echo '
'; // print_r($eList); // echo ''; foreach ($eList as $item) { // col50 (3000 길이) 처리 if(intval($item['col50']) > 0) { $bottombar_rows[] = [ 'size' => '60x40', 'length' => 3000, 'sum' => intval($item['col50']) ]; } // col51 (4000 길이) 처리 if(intval($item['col51']) > 0) { $bottombar_rows[] = [ 'size' => '60x40', 'length' => 4000, 'sum' => intval($item['col51']) ]; } } unset($row); // 참조 제거 // 중복 제거 $bottombar_rows = array_map('unserialize', array_unique(array_map('serialize', $bottombar_rows))); // 하단마감재 if(!empty($bottombar_rows)) { foreach ($bottombar_rows as $index => $item) { switch ($prodType) { // 마감형태에 따른 정의 case 'S1': case 'S2': $tempData = [ [ '분류' => $prodCode , '품명' => '하단마감재', '타입' => $item['size'], '길이' => [ ['도면치수' => $item['length'] , '측정값' => null] ], '너비' => [ ['도면치수' => 'N/A', '측정값' => 'N/A'] ], '간격' => [ ['POINT' => '(1)', '도면치수' => 60 , '측정값' => null] ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'bottombar_KTE01KQTS01', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); break; case 'S3': $tempData = [ [ '분류' => $prodCode , '품명' => '하단마감재', '타입' => '(별도마감형태) '. $item['size'], '길이' => [ ['도면치수' => $item['length'] , '측정값' => null], ], '너비' => [ ['도면치수' => 'N/A', '측정값' => 'N/A'], ], '간격' => [ ['POINT' => '(1)', '도면치수' => 60 , '측정값' => null], ['POINT' => '(2)', '도면치수' => 64 , '측정값' => null], ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'bottombar_KTE01KQTS01_add', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); break; } } } ?> '1219', 'quantity' => intval($item['col39'])], ['length' => '2438', 'quantity' => intval($item['col40'])], ['length' => '3000', 'quantity' => intval($item['col41'])], ['length' => '3500', 'quantity' => intval($item['col42'])], ['length' => '4000', 'quantity' => intval($item['col43'])], ['length' => '4150', 'quantity' => intval($item['col44'])] ]; $existingKey = array_search($boxSize, array_column($box_data, 'size')); if ($existingKey === false) { // 새로운 사이즈 추가 $box_data[] = [ 'size' => $boxSize, 'sum' => 1, 'cover' => $cover, 'fincover' => $fincover, 'boxdirection' => $boxdirection, 'frontbottom' => $frontbottom, 'railwidth' => $railwidth, 'length' => array_map(function ($length) { return ['length' => $length['length'], 'sum' => $length['quantity']]; }, $boxLengths) ]; } else { // 기존 데이터에 값 누적 $box_data[$existingKey]['sum'] += 1; $box_data[$existingKey]['cover'] += $cover; $box_data[$existingKey]['fincover'] += $fincover; // 길이 데이터 누적 foreach ($boxLengths as $length) { // $box_data에서 해당 길이 찾기 $key = array_search($length['length'], array_column($box_data[$existingKey]['length'], 'length')); if ($key !== false) { $box_data[$existingKey]['length'][$key]['sum'] += $length['quantity']; } else { echo "길이 {$length['length']}를 찾을 수 없습니다.\n"; // 디버깅 메시지 } } } } // echo '
'; // print_r($box_data); // echo ''; // length에서 sum이 0인 항목 제거 foreach ($box_data as $key => &$box) { $box['length'] = array_filter($box['length'], function ($lengthItem) { return $lengthItem['sum'] > 0; // sum 값이 0보다 큰 항목만 유지 }); } // // 결과 출력 // echo '
'; // print_r($box_data); // echo ''; if(!empty($box_data)) { foreach ($box_data as $index => $item) { list($boxwidth, $boxheight) = explode('*', $item['size']); foreach ($item['length'] as $index => $lengths) { switch ($item['boxdirection']) { // 박스 점검구 방향에 따라 case '양면': $tempData = [ [ '분류' => $prodCode , '품명' => '케이스', '타입' => $item['size'] . ' ' . $item['boxdirection'] . ' 점검구' , '길이' => [ ['도면치수' => $lengths['length'] , '측정값' => null] ], '너비' => [ ['도면치수' => 'N/A', '측정값' => 'N/A'] ], '간격' => [ ['POINT' => '(1)', '도면치수' => $boxheight , '측정값' => null], ['POINT' => '(2)', '도면치수' => $frontbottom , '측정값' => null], ['POINT' => '(3)', '도면치수' => ($boxwidth - $frontbottom - $railwidth - 140) , '측정값' => null], ['POINT' => '(4)', '도면치수' => $frontbottom , '측정값' => null], ['POINT' => '(5)', '도면치수' => ($boxheight - 140) , '측정값' => null], ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'box_both', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); break; case '밑면': $tempData = [ [ '분류' => $prodCode , '품명' => '케이스', '타입' => $item['size'] . ' ' . $item['boxdirection'] . ' 점검구' , '길이' => [ ['도면치수' => $lengths['length'] , '측정값' => null] ], '너비' => [ ['도면치수' => 'N/A', '측정값' => 'N/A'] ], '간격' => [ ['POINT' => '(1)', '도면치수' => $boxheight , '측정값' => null], ['POINT' => '(2)', '도면치수' => 50 , '측정값' => null], ['POINT' => '(3)', '도면치수' => ($boxwidth - $frontbottom - $railwidth - 140) , '측정값' => null], ['POINT' => '(4)', '도면치수' => $boxheight , '측정값' => null], ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'box_bottom', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); break; case '후면': $tempData = [ [ '분류' => $prodCode , '품명' => '케이스', '타입' => $item['size'] . ' ' . $item['boxdirection'] . ' 점검구' , '길이' => [ ['도면치수' => $lengths['length'] , '측정값' => null] ], '너비' => [ ['도면치수' => 'N/A', '측정값' => 'N/A'] ], '간격' => [ ['POINT' => '(1)', '도면치수' => $boxheight , '측정값' => null], ['POINT' => '(2)', '도면치수' => ($boxwidth - $frontbottom - $railwidth ) , '측정값' => null], ['POINT' => '(3)', '도면치수' => ($boxheight - 140) , '측정값' => null], ['POINT' => '(4)', '도면치수' => 50 , '측정값' => null] ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'box_rear', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); break; } } } } ?> 2438, 'sum' => 0], ['length' => 3000, 'sum' => 0], ['length' => 3500, 'sum' => 0], ['length' => 4000, 'sum' => 0], ['length' => 4300, 'sum' => 0] ]; $smoke_rows = []; foreach ($eList as $item) { $validLength = floatval($item['col24']); // 가이드레일 유효 길이 foreach ($smoke_data as &$row) { if ($validLength <= $row['length']) { $row['sum'] = 1; $smoke_rows[] = ['length' => $row['length'], 'sum' => 1]; break; } } } unset($row); // 참조 제거 // echo '
'; // print_r($smoke_rows); // echo ''; // 가장 큰 length 값을 가진 배열 요소 추출 $max_length_row = array_reduce($smoke_rows, function ($carry, $item) { return $item['length'] > ($carry['length'] ?? 0) ? $item : $carry; }, []); // 가장 큰 length 값을 가진 요소의 인덱스 찾기 $max_length_index = null; $max_length_value = 0; foreach ($smoke_rows as $index => $item) { if ($item['length'] > $max_length_value) { $max_length_value = $item['length']; $max_length_index = $index; // 최대값의 인덱스 저장 } } if ($max_length_index !== null) { $item = $smoke_rows[$max_length_index]; $tempData = [ [ '분류' => $prodCode, '품명' => '연기차단재', '타입' => 'W50(가이드레일용)', '길이' => [ ['도면치수' => $item['length'], '측정값' => null] ], '너비' => [ ['도면치수' => '(1) 50', '측정값' => null] ], '간격' => [ ['POINT' => '(2)', '도면치수' => 12, '측정값' => null] ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'smoke', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); } ?> 3000, 'sum' => 0], ]; $smoke_rows = []; foreach ($eList as $item) { $validSurang = floatval($item['col48']); // 셔터박스용 연기차단제 수량 foreach ($smoke_data as &$row) { $row['sum'] = $validSurang; $smoke_rows[] = ['length' => $row['length'], 'sum' => $row['sum'] ]; } } unset($row); // 참조 제거 // 중복 제거 $unique_smoke_rows = array_values(array_reduce($smoke_rows, function ($carry, $item) { $carry[$item['length']] = $item; // length를 키로 사용 return $carry; }, [])); if(!empty($unique_smoke_rows)) { foreach ($unique_smoke_rows as $index => $item) { $tempData = [ [ '분류' => $prodCode , '품명' => '연기차단재', '타입' => 'W80(케이스용)', '길이' => [ ['도면치수' => $item['length'] , '측정값' => null] ], '너비' => [ ['도면치수' => '(1) 80', '측정값' => null ] ], '간격' => [ ['POINT' => '(2)', '도면치수' => 12 , '측정값' => null], ], '판정' => null, // 적합 여부 (적/부) '이미지' => 'smoke', ] ]; $guiderailArray = array_merge($guiderailArray, $tempData); } } ?>