|
|
@@ -1366,7 +1366,7 @@ class OrderSuperLoss extends Api
|
|
|
->value('rtrim(规格)');
|
|
|
$moneyRate = (strpos((string)$guige, '小盒') !== false) ? 0.02 : 0.09;
|
|
|
|
|
|
- //计算超节损金额(班组行先汇总废品,节损数/金额按工序级:工序计划损耗 - 报废合计)
|
|
|
+ //计算超节损金额(工序合计不变,节损数和金额按班组行分摊,尾差补到该工序最后一行)
|
|
|
foreach ($gy_data as $n => $item) {
|
|
|
$gy_data[$n]['sys_ny'] = date('Ym', strtotime($workOrderData['jjcp_sj']));
|
|
|
$gy_data[$n]['超节损核算单价'] = $moneyRate;
|
|
|
@@ -1410,13 +1410,15 @@ class OrderSuperLoss extends Api
|
|
|
$data['reward_rate'] = $this->stringifyRewardMultiplier($rewardMultiplier);
|
|
|
$total['reward'] = 0;
|
|
|
foreach ($processGxSummary as $summary) {
|
|
|
- if ($this->isMachineInspectionProcess((string)$summary['gxmc'])) {
|
|
|
+ $machine = $this->isMachineInspectionProcess((string)$summary['gxmc']);
|
|
|
+ $excluded = $this->isSuperLossRewardExcluded((string)$summary['gxmc']);
|
|
|
+ if ($machine) {
|
|
|
$processCjsSl = $summary['plan_loss'] - $summary['intangible'];
|
|
|
} else {
|
|
|
$totalWaste = $summary['zcfp'] + $summary['zj'] + $summary['intangible'];
|
|
|
$processCjsSl = $summary['plan_loss'] - $totalWaste;
|
|
|
}
|
|
|
- if ($this->isSuperLossRewardExcluded((string)$summary['gxmc'])) {
|
|
|
+ if ($excluded) {
|
|
|
$processCjsJe = 0.0;
|
|
|
} else {
|
|
|
$processCjsJe = $processCjsSl * floatval($summary['ratio']) * $moneyRate;
|
|
|
@@ -1424,15 +1426,40 @@ class OrderSuperLoss extends Api
|
|
|
if ($rewardMultiplier > 1 && $processCjsJe != 0.0) {
|
|
|
$processCjsJe *= $rewardMultiplier;
|
|
|
}
|
|
|
- foreach ($summary['row_indexes'] as $idx => $n) {
|
|
|
- if ($idx === 0) {
|
|
|
- $gy_data[$n]['节损数量'] = $processCjsSl;
|
|
|
- $gy_data[$n]['节损奖'] = number_format($processCjsJe, 4);
|
|
|
+ $processCjsJe = round($processCjsJe, 4);
|
|
|
+
|
|
|
+ $indexes = $summary['row_indexes'];
|
|
|
+ $last = count($indexes) - 1;
|
|
|
+ $rowSl = [];
|
|
|
+ $slSum = 0;
|
|
|
+ foreach ($indexes as $idx => $n) {
|
|
|
+ $item = $gy_data[$n];
|
|
|
+ $rowWaste = (int)$item['sczl_zcfp'] + (int)$item['质检废'] + (int)$item['无形损分摊'];
|
|
|
+ $rowSl[$idx] = (int)$item['计划损耗'] - $rowWaste;
|
|
|
+ $slSum += $rowSl[$idx];
|
|
|
+ }
|
|
|
+ $rowSl[$last] += $processCjsSl - $slSum;
|
|
|
+
|
|
|
+ $rowJe = [];
|
|
|
+ $jeSum = 0.0;
|
|
|
+ foreach ($indexes as $idx => $n) {
|
|
|
+ if ($excluded) {
|
|
|
+ $je = 0.0;
|
|
|
} else {
|
|
|
- $gy_data[$n]['节损数量'] = 0;
|
|
|
- $gy_data[$n]['节损奖'] = '0.0000';
|
|
|
+ $je = $rowSl[$idx] * floatval($summary['ratio']) * $moneyRate;
|
|
|
+ if ($rewardMultiplier > 1 && $je != 0.0) {
|
|
|
+ $je *= $rewardMultiplier;
|
|
|
+ }
|
|
|
}
|
|
|
- $total['reward'] += floatval(str_replace(',', '', (string)$gy_data[$n]['节损奖']));
|
|
|
+ $rowJe[$idx] = round($je, 4);
|
|
|
+ $jeSum += $rowJe[$idx];
|
|
|
+ }
|
|
|
+ $rowJe[$last] = round($rowJe[$last] + ($processCjsJe - round($jeSum, 4)), 4);
|
|
|
+
|
|
|
+ foreach ($indexes as $idx => $n) {
|
|
|
+ $gy_data[$n]['节损数量'] = $rowSl[$idx];
|
|
|
+ $gy_data[$n]['节损奖'] = number_format($rowJe[$idx], 4);
|
|
|
+ $total['reward'] += $rowJe[$idx];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1821,10 +1848,10 @@ class OrderSuperLoss extends Api
|
|
|
->field('CONCAT(rtrim(Gy0_gxmc),"[",rtrim(Add_gxmc),"]") as 工序名称,Gy0_ls as 联数')
|
|
|
->select();
|
|
|
|
|
|
- $status = \db('工单_印件资料')
|
|
|
- ->where('Yj_Gdbh', $param['order'])
|
|
|
- ->where('yj_Yjno', $param['yjno'])
|
|
|
- ->value('质量考核');
|
|
|
+ $status = \db('工单_印件资料')
|
|
|
+ ->where('Yj_Gdbh', $param['order'])
|
|
|
+ ->where('yj_Yjno', $param['yjno'])
|
|
|
+ ->value('质量考核');
|
|
|
|
|
|
// 添加到 $list 数组中
|
|
|
$list['质量考核'] = $status;
|
|
|
@@ -1856,6 +1883,7 @@ class OrderSuperLoss extends Api
|
|
|
? number_format(((int)$storedRule['target_rate_bp']) / 100, 2) . '%'
|
|
|
: number_format($targetRateVal, 2) . '%';
|
|
|
$list['real_rate'] = number_format($realRateVal, 2) . '%';
|
|
|
+ $list['计算规则'] = $this->formatSuperLossRewardRule($this->superLossRewardRule);
|
|
|
|
|
|
//查询工序数据(字段名与历史 ProcessLoss 一致)
|
|
|
$gy_field = '
|
|
|
@@ -2635,7 +2663,7 @@ class OrderSuperLoss extends Api
|
|
|
$strFields = [
|
|
|
'Gd_gdbh', 'yjno', 'ls', '成品代号', '成品名称', '计量单位', 'warehousing_date',
|
|
|
'warehousing_num', '计划损耗', '废品合计', 'intangible_loss', '材料废', '零头处理',
|
|
|
- '外发废', 'zcfp', '班组分摊质检废品', '订单数量', '销售订单号', 'target_rate', 'real_rate', 'reward_rate', '考核',
|
|
|
+ '外发废', 'zcfp', '班组分摊质检废品', '订单数量', '销售订单号', 'target_rate', 'real_rate', 'reward_rate', '计算规则', '考核',
|
|
|
];
|
|
|
foreach ($strFields as $f) {
|
|
|
if (array_key_exists($f, $list)) {
|
|
|
@@ -3238,6 +3266,57 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 本工单命中的表2奖罚规则。材料报废率超过1.5%且没有索赔时返回例外说明。
|
|
|
+ */
|
|
|
+ private function formatSuperLossRewardRule(?array $rule): string
|
|
|
+ {
|
|
|
+ if (empty($rule)) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ if (!empty($rule['claim_exempt'])) {
|
|
|
+ return '材料原因报废率超过1.5%且没有索赔,不加大奖罚';
|
|
|
+ }
|
|
|
+ $tierCode = (string)($rule['tier'] ?? '');
|
|
|
+ if ($tierCode === '') {
|
|
|
+ return '奖罚1倍';
|
|
|
+ }
|
|
|
+ $labels = [
|
|
|
+ '>=97' => '≥97%',
|
|
|
+ '95-97' => '95%–97%',
|
|
|
+ '90-95' => '90%–95%',
|
|
|
+ '80-90' => '80%–90%',
|
|
|
+ '<=80' => '≤80%',
|
|
|
+ ];
|
|
|
+ $label = isset($labels[$tierCode]) ? $labels[$tierCode] : $tierCode;
|
|
|
+ $multiplierBp = (int)($rule['multiplier_bp'] ?? 100);
|
|
|
+ if (empty($rule['hit'])) {
|
|
|
+ $conf = SuperLossRewardRule::config();
|
|
|
+ foreach ($conf['tiers'] as $tier) {
|
|
|
+ if ((string)$tier['tier'] === $tierCode) {
|
|
|
+ $multiplierBp = (int)$tier['multiplier_bp'];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $high = $this->formatRewardPoint((int)($rule['high_bp'] ?? 0));
|
|
|
+ $low = $this->formatRewardPoint((int)($rule['low_bp'] ?? 0));
|
|
|
+ $multiplier = $this->stringifyRewardMultiplier($multiplierBp / 100);
|
|
|
+
|
|
|
+ return '目标合格率' . $label . ',超出目标合格率' . $high . '个点,低于目标合格率' . $low . '个点,奖罚' . $multiplier . '倍';
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基点换算成表2里的“个点”:150 -> 1.5,200 -> 2.0,300 -> 3
|
|
|
+ */
|
|
|
+ private function formatRewardPoint(int $bp): string
|
|
|
+ {
|
|
|
+ if ($bp % 100 === 0 && $bp >= 300) {
|
|
|
+ return (string)(int)($bp / 100);
|
|
|
+ }
|
|
|
+ return number_format($bp / 100, 1, '.', '');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 倍率统一格式化为 1 / 1.3 / 1.6,避免 1.30 这类展示差异
|
|
|
*/
|