80 lines
2.5 KiB
PHP
80 lines
2.5 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* 컷팅 매수 계산
|
||
|
|
*
|
||
|
|
* @param string $itemSelect '실리카'|'와이어'|'화이바'
|
||
|
|
* @param int $height 원단 세로 길이(mm)
|
||
|
|
* @return array [
|
||
|
|
* 'firstCut' => 전체 절단 횟수,
|
||
|
|
* '900' => 900 규격 매수(0 or 1),
|
||
|
|
* '800' => 800 규격 매수(0 or 1),
|
||
|
|
* '600' => 600 규격 매수(0 or 1),
|
||
|
|
* '400' => 400 규격 매수(0 or 1),
|
||
|
|
* '300' => 300 규격 매수(0 or 1),
|
||
|
|
* 'remaining'=> 최종 남은 높이(mm)
|
||
|
|
* ]
|
||
|
|
*/
|
||
|
|
function calculateCutSize(string $itemSelect, int $height): array {
|
||
|
|
|
||
|
|
// 1) 기준 폭 선택
|
||
|
|
switch ($itemSelect) {
|
||
|
|
case (strpos($itemSelect, '실리') !== false): $value = 1220; $threshold = 940; $itemSelect='실리카'; break;
|
||
|
|
case (strpos($itemSelect, '와이어') !== false): $value = 1180; $threshold = 900; $itemSelect='와이어'; break;
|
||
|
|
case (strpos($itemSelect, '화이') !== false): $value = 1200; $threshold = 924; $itemSelect='화이바'; break;
|
||
|
|
default:
|
||
|
|
throw new InvalidArgumentException("지원하지 않는 원단: {$itemSelect}");
|
||
|
|
}
|
||
|
|
|
||
|
|
// 2) 시접 추가
|
||
|
|
$makeVertical = $height
|
||
|
|
+ 140
|
||
|
|
+ floor($height / $value) * 40;
|
||
|
|
|
||
|
|
// 3) 기본 절단 횟수
|
||
|
|
$firstCut = (int) floor($makeVertical / $value);
|
||
|
|
|
||
|
|
// 4) 남은 높이 계산
|
||
|
|
$remaining = $makeVertical - ($firstCut * $value);
|
||
|
|
|
||
|
|
// 5) 남은 높이가 임계치 넘으면 추가 절단
|
||
|
|
if ($remaining > $threshold) {
|
||
|
|
$firstCut++;
|
||
|
|
// $remaining -= $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 6) 공차별 분류 범위 정의
|
||
|
|
$ranges = [
|
||
|
|
'실리카' => [
|
||
|
|
'900' => [841, 940],
|
||
|
|
'800' => [641, 840],
|
||
|
|
'600' => [441, 640],
|
||
|
|
'400' => [341, 440],
|
||
|
|
'300' => [ 1, 340],
|
||
|
|
],
|
||
|
|
'와이어' => [
|
||
|
|
'900' => [801, 900],
|
||
|
|
'800' => [601, 800],
|
||
|
|
'600' => [401, 600],
|
||
|
|
'400' => [301, 400],
|
||
|
|
'300' => [ 1, 300],
|
||
|
|
],
|
||
|
|
'화이바' => [
|
||
|
|
'900' => [825, 924],
|
||
|
|
'800' => [625, 824],
|
||
|
|
'600' => [425, 624],
|
||
|
|
'400' => [325, 424],
|
||
|
|
'300' => [ 1, 324],
|
||
|
|
],
|
||
|
|
];
|
||
|
|
|
||
|
|
// 7) 결과 배열 구성
|
||
|
|
$result = [
|
||
|
|
'firstCut' => $firstCut,
|
||
|
|
'remaining' => $remaining,
|
||
|
|
];
|
||
|
|
foreach ($ranges[$itemSelect] as $key => [$min, $max]) {
|
||
|
|
$result[$key] = ($remaining >= $min && $remaining <= $max) ? 1 : 0;
|
||
|
|
}
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
?>
|