|
@@ -221,8 +221,8 @@ class OrderSuperLoss extends Api
|
|
|
])
|
|
])
|
|
|
->group('a.Gy0_yjno,a.Gy0_gxh')
|
|
->group('a.Gy0_yjno,a.Gy0_gxh')
|
|
|
->select();
|
|
->select();
|
|
|
- //目标合格率:统一走整数基点口径(10000 - Σ 工序计划损耗率),避免浮点边界与多套公式
|
|
|
|
|
- $target_rate = $this->calcTargetRateBp($order, $params['yjno'], $gxh_values) / 100;
|
|
|
|
|
|
|
+ //目标合格率 = (投料数 - 参与工序计划损耗合计) / 投料数
|
|
|
|
|
+ $target_rate = $this->calcTargetRateBp($order, $params['yjno'], $gxh_values, (float)$data['实际投料'] * 10000) / 100;
|
|
|
$data['target_rate'] = number_format($target_rate, 2) . '%'; //目标合格率
|
|
$data['target_rate'] = number_format($target_rate, 2) . '%'; //目标合格率
|
|
|
$real_rate = $cp_data[0]['cp_sl'] / ((float)$data['实际投料'] * 10000) *100;
|
|
$real_rate = $cp_data[0]['cp_sl'] / ((float)$data['实际投料'] * 10000) *100;
|
|
|
$data['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
|
|
$data['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
|
|
@@ -1333,7 +1333,8 @@ class OrderSuperLoss extends Api
|
|
|
$targetRateVal = $this->calcSuperLossTargetQualificationRate(
|
|
$targetRateVal = $this->calcSuperLossTargetQualificationRate(
|
|
|
$workOrderData['jjcp_gdbh'],
|
|
$workOrderData['jjcp_gdbh'],
|
|
|
$workOrderData['jjcp_yjno'],
|
|
$workOrderData['jjcp_yjno'],
|
|
|
- $gxh_values
|
|
|
|
|
|
|
+ $gxh_values,
|
|
|
|
|
+ $feedQty
|
|
|
);
|
|
);
|
|
|
$data['target_rate'] = number_format($targetRateVal, 2) . '%';
|
|
$data['target_rate'] = number_format($targetRateVal, 2) . '%';
|
|
|
//单据列表最后统计/数据汇总
|
|
//单据列表最后统计/数据汇总
|
|
@@ -1928,12 +1929,11 @@ class OrderSuperLoss extends Api
|
|
|
$list[$key]['考核'] = ($status == 1) ? '否' : '是';
|
|
$list[$key]['考核'] = ($status == 1) ? '否' : '是';
|
|
|
if ($value['实际投料'] !== null){
|
|
if ($value['实际投料'] !== null){
|
|
|
$actualMaterial = $value['实际投料'] * 10000;
|
|
$actualMaterial = $value['实际投料'] * 10000;
|
|
|
- if (isset($value['target_rate_bp']) && $value['target_rate_bp'] !== null) {
|
|
|
|
|
- //以核算时落库的整数基点为准,保证列表与明细/工资口径一致
|
|
|
|
|
- $list[$key]['target_rate'] = number_format(((int)$value['target_rate_bp']) / 100, 2) . '%';
|
|
|
|
|
- } else {
|
|
|
|
|
- $list[$key]['target_rate'] = $this->calculateRate($actualMaterial, $value['工单计划损耗']);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $gxhValues = $this->getSuperLossProcessGxhList($value['Gd_gdbh'], $value['jjcp_yjno']);
|
|
|
|
|
+ $list[$key]['target_rate'] = number_format(
|
|
|
|
|
+ $this->calcTargetRateBp($value['Gd_gdbh'], $value['jjcp_yjno'], $gxhValues, $actualMaterial) / 100,
|
|
|
|
|
+ 2
|
|
|
|
|
+ ) . '%';
|
|
|
$list[$key]['real_rate'] = $value['warehousing_num']/($value['实际投料']*10000)*100;
|
|
$list[$key]['real_rate'] = $value['warehousing_num']/($value['实际投料']*10000)*100;
|
|
|
$list[$key]['real_rate'] = number_format($list[$key]['real_rate'], 2).'%';
|
|
$list[$key]['real_rate'] = number_format($list[$key]['real_rate'], 2).'%';
|
|
|
}else{
|
|
}else{
|
|
@@ -2029,7 +2029,8 @@ class OrderSuperLoss extends Api
|
|
|
$targetRateVal = $this->calcSuperLossTargetQualificationRate(
|
|
$targetRateVal = $this->calcSuperLossTargetQualificationRate(
|
|
|
$param['order'],
|
|
$param['order'],
|
|
|
$param['yjno'],
|
|
$param['yjno'],
|
|
|
- $gxhValues
|
|
|
|
|
|
|
+ $gxhValues,
|
|
|
|
|
+ $feedQty
|
|
|
);
|
|
);
|
|
|
$realRateVal = $feedQty > 0 ? (floatval($list['warehousing_num']) / $feedQty * 100) : 0.0;
|
|
$realRateVal = $feedQty > 0 ? (floatval($list['warehousing_num']) / $feedQty * 100) : 0.0;
|
|
|
//倍率:优先用核算时落库的结果,保证明细与列表、工资口径一致;未核算过再按规则实时计算
|
|
//倍率:优先用核算时落库的结果,保证明细与列表、工资口径一致;未核算过再按规则实时计算
|
|
@@ -2045,9 +2046,7 @@ class OrderSuperLoss extends Api
|
|
|
$list['reward_rate'] = isset($storedRule['reward_multiplier']) && $storedRule['reward_multiplier'] !== null
|
|
$list['reward_rate'] = isset($storedRule['reward_multiplier']) && $storedRule['reward_multiplier'] !== null
|
|
|
? $this->stringifyRewardMultiplier($storedRule['reward_multiplier'])
|
|
? $this->stringifyRewardMultiplier($storedRule['reward_multiplier'])
|
|
|
: $this->stringifyRewardMultiplier($rewardMultiplier);
|
|
: $this->stringifyRewardMultiplier($rewardMultiplier);
|
|
|
- $list['target_rate'] = isset($storedRule['target_rate_bp']) && $storedRule['target_rate_bp'] !== null
|
|
|
|
|
- ? number_format(((int)$storedRule['target_rate_bp']) / 100, 2) . '%'
|
|
|
|
|
- : number_format($targetRateVal, 2) . '%';
|
|
|
|
|
|
|
+ $list['target_rate'] = number_format($targetRateVal, 2) . '%';
|
|
|
$list['real_rate'] = number_format($realRateVal, 2) . '%';
|
|
$list['real_rate'] = number_format($realRateVal, 2) . '%';
|
|
|
$list['计算规则'] = $this->formatSuperLossRewardRule($this->superLossRewardRule);
|
|
$list['计算规则'] = $this->formatSuperLossRewardRule($this->superLossRewardRule);
|
|
|
|
|
|
|
@@ -2215,10 +2214,11 @@ class OrderSuperLoss extends Api
|
|
|
$list['考核'] = ($status == 1) ? '不参与考核' : '参与考核';
|
|
$list['考核'] = ($status == 1) ? '不参与考核' : '参与考核';
|
|
|
|
|
|
|
|
$list['实际投料'] = $list['实际投料']*10000;
|
|
$list['实际投料'] = $list['实际投料']*10000;
|
|
|
- //目标合格率
|
|
|
|
|
- $list['target_rate'] = ($list['实际投料']-$list['计划损耗'])/$list['实际投料']*100;
|
|
|
|
|
- $list['target_rate'] = number_format($list['target_rate'],2);
|
|
|
|
|
- $list['target_rate'] = $list['target_rate'].'%';
|
|
|
|
|
|
|
+ $classGxhValues = $this->getSuperLossProcessGxhList($param['order'], $param['yjno']);
|
|
|
|
|
+ $list['target_rate'] = number_format(
|
|
|
|
|
+ $this->calcTargetRateBp($param['order'], $param['yjno'], $classGxhValues, floatval($list['实际投料'])) / 100,
|
|
|
|
|
+ 2
|
|
|
|
|
+ ) . '%';
|
|
|
//实际合格率
|
|
//实际合格率
|
|
|
|
|
|
|
|
$list['real_rate'] = $list['warehousing_num']/($list['实际投料'])*100;
|
|
$list['real_rate'] = $list['warehousing_num']/($list['实际投料'])*100;
|
|
@@ -3160,43 +3160,51 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 目标合格率(整数基点,端点统一):10000 - Σ round(工序计划损耗 / 计划接货数 * 10000)
|
|
|
|
|
- *
|
|
|
|
|
- * 全项目唯一口径:判定、列表、明细、决策看板均通过本方法(或落库的 target_rate_bp)取目标合格率,
|
|
|
|
|
- * 不再使用“计划损耗 / 实际投料”的口径,避免同工单不同页面数值不一致。
|
|
|
|
|
|
|
+ * 参与超节损的工序计划损耗合计:每道工序 Gy0_计划损耗 × 联数 × 开数,按工序号只计一次
|
|
|
*/
|
|
*/
|
|
|
- private function calcTargetRateBp(string $gdbh, string $yjno, array $gxhValues): int
|
|
|
|
|
|
|
+ private function sumSuperLossPlanLoss(string $gdbh, string $yjno, array $gxhValues): float
|
|
|
{
|
|
{
|
|
|
if (empty($gxhValues)) {
|
|
if (empty($gxhValues)) {
|
|
|
- return 10000;
|
|
|
|
|
|
|
+ return 0.0;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
$rows = db('工单_工艺资料')
|
|
$rows = db('工单_工艺资料')
|
|
|
- ->alias('a')
|
|
|
|
|
- ->field('a.Gy0_计划损耗, a.Gy0_计划接货数 * a.Gy0_ls as Gy0_计划接货数')
|
|
|
|
|
- ->where(['a.Gy0_gdbh' => $gdbh, 'a.Gy0_yjno' => $yjno, 'a.Gy0_gxh' => ['in', $gxhValues]])
|
|
|
|
|
- ->group('a.Gy0_gxh')
|
|
|
|
|
|
|
+ ->where(['Gy0_gdbh' => $gdbh, 'Gy0_yjno' => $yjno, 'Gy0_gxh' => ['in', $gxhValues]])
|
|
|
|
|
+ ->field('Gy0_gxh, MAX(Gy0_计划损耗 * Gy0_ls * Gy0_ks) AS plan_loss')
|
|
|
|
|
+ ->group('Gy0_gxh')
|
|
|
->select();
|
|
->select();
|
|
|
-
|
|
|
|
|
- $sumBp = 0;
|
|
|
|
|
|
|
+ $sum = 0.0;
|
|
|
foreach ($rows as $row) {
|
|
foreach ($rows as $row) {
|
|
|
- $denominator = floatval($row['Gy0_计划接货数']);
|
|
|
|
|
- if ($denominator <= 0) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- $sumBp += (int)round(floatval($row['Gy0_计划损耗']) / $denominator * SuperLossRewardRule::BP_BASE);
|
|
|
|
|
|
|
+ $sum += floatval($row['plan_loss']);
|
|
|
}
|
|
}
|
|
|
|
|
+ return $sum;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $bp = SuperLossRewardRule::BP_BASE - $sumBp;
|
|
|
|
|
- return $bp < 0 ? 0 : $bp;
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 目标合格率(整数基点):(投料数 - 参与工序计划损耗合计) / 投料数
|
|
|
|
|
+ * 投料数与实际投料同一单位,调用方传入 实际投料 × 10000。
|
|
|
|
|
+ */
|
|
|
|
|
+ private function calcTargetRateBp(string $gdbh, string $yjno, array $gxhValues, float $feedQty): int
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($feedQty <= 0) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $planLoss = $this->sumSuperLossPlanLoss($gdbh, $yjno, $gxhValues);
|
|
|
|
|
+ $bp = (int)round(($feedQty - $planLoss) / $feedQty * SuperLossRewardRule::BP_BASE);
|
|
|
|
|
+ if ($bp < 0) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($bp > SuperLossRewardRule::BP_BASE) {
|
|
|
|
|
+ return SuperLossRewardRule::BP_BASE;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $bp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 目标合格率(百分数,保留两位);历史调用点使用,内部委托 calcTargetRateBp
|
|
|
|
|
|
|
+ * 目标合格率(百分数,保留两位)
|
|
|
*/
|
|
*/
|
|
|
- private function calcSuperLossTargetQualificationRate(string $gdbh, string $yjno, array $gxhValues): float
|
|
|
|
|
|
|
+ private function calcSuperLossTargetQualificationRate(string $gdbh, string $yjno, array $gxhValues, float $feedQty): float
|
|
|
{
|
|
{
|
|
|
- return $this->calcTargetRateBp($gdbh, $yjno, $gxhValues) / 100;
|
|
|
|
|
|
|
+ return $this->calcTargetRateBp($gdbh, $yjno, $gxhValues, $feedQty) / 100;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|