|
|
@@ -318,6 +318,11 @@ class OrderSuperLoss extends Api
|
|
|
//无形损
|
|
|
if ($this->isSuperLossIntangibleExcluded((string)$item['Gy0_gxmc'])) {
|
|
|
$gy_data[$k]['intangible_loss'] = 0;
|
|
|
+ } elseif ($this->isMachineInspectionProcess((string)$item['Gy0_gxmc'])) {
|
|
|
+ $planTotalAll = $this->getIntangiblePlanLossTotalAll($order, $params['yjno'], $gxh_values);
|
|
|
+ $gy_data[$k]['intangible_loss'] = $planTotalAll > 0
|
|
|
+ ? (int)round($gy_data[$k]['Gy0_计划损耗'] / $planTotalAll * $data['intangible_loss'])
|
|
|
+ : 0;
|
|
|
} elseif (floatval($item['无形损承担比例']) > 0) {
|
|
|
$gy_data[$k]['intangible_loss'] = round(number_format($gy_data[$k]['Gy0_计划损耗'] / $plan_total, 4) * $data['intangible_loss'] * floatval($item['无形损承担比例']));
|
|
|
} else {
|
|
|
@@ -1161,6 +1166,11 @@ class OrderSuperLoss extends Api
|
|
|
$workOrderData['jjcp_yjno'],
|
|
|
$gxh_values
|
|
|
);
|
|
|
+ $plan_total_all = $this->getIntangiblePlanLossTotalAll(
|
|
|
+ $workOrderData['jjcp_gdbh'],
|
|
|
+ $workOrderData['jjcp_yjno'],
|
|
|
+ $gxh_values
|
|
|
+ );
|
|
|
$targetRateVal = $this->calcSuperLossTargetQualificationRate(
|
|
|
$workOrderData['jjcp_gdbh'],
|
|
|
$workOrderData['jjcp_yjno'],
|
|
|
@@ -1241,6 +1251,12 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
|
|
|
|
foreach ($gy_data as $kk => $vv) {
|
|
|
+ $this->fillSczlTeamMemberFields(
|
|
|
+ $gy_data[$kk],
|
|
|
+ $workOrderData['jjcp_gdbh'],
|
|
|
+ $workOrderData['jjcp_yjno']
|
|
|
+ );
|
|
|
+ $vv = $gy_data[$kk];
|
|
|
$banju = $vv['版距']/1000;
|
|
|
if ($vv['印刷方式'] === '卷对卷'){
|
|
|
$vv['total_cl'] = $vv['total_cl']*$banju;
|
|
|
@@ -1308,13 +1324,13 @@ class OrderSuperLoss extends Api
|
|
|
$gy_data[$kk]['计划损耗'] ?? 0,
|
|
|
$gy_data[$kk]['Gy0_计划损耗'] ?? ($vv['Gy0_计划损耗'] ?? 0),
|
|
|
$plan_total,
|
|
|
- floatval($data['intangible_loss'])
|
|
|
+ floatval($data['intangible_loss']),
|
|
|
+ $plan_total_all
|
|
|
);
|
|
|
if ($this->isMachineInspectionProcess((string)$gy_data[$kk]['sczl_gxmc'])) {
|
|
|
$gy_data[$kk]['质检废'] = 0;
|
|
|
$gy_data[$kk]['zjfp'] = 0;
|
|
|
$gy_data[$kk]['sczl_zcfp'] = 0;
|
|
|
- $gy_data[$kk]['无形损分摊'] = 0;
|
|
|
}
|
|
|
//班组成员
|
|
|
for ($j = 1; $j <= 10; $j++) {
|
|
|
@@ -1396,7 +1412,7 @@ class OrderSuperLoss extends Api
|
|
|
$total['reward'] = 0;
|
|
|
foreach ($processGxSummary as $summary) {
|
|
|
if ($this->isMachineInspectionProcess((string)$summary['gxmc'])) {
|
|
|
- $processCjsSl = $summary['plan_loss'];
|
|
|
+ $processCjsSl = $summary['plan_loss'] - $summary['intangible'];
|
|
|
} else {
|
|
|
$totalWaste = $summary['zcfp'] + $summary['zj'] + $summary['intangible'];
|
|
|
$processCjsSl = $summary['plan_loss'] - $totalWaste;
|
|
|
@@ -2315,10 +2331,10 @@ class OrderSuperLoss extends Api
|
|
|
return 'CONCAT(rtrim(a.Gy0_gxmc), IF(a.Add_gxmc IS NULL OR rtrim(a.Add_gxmc) = \'\', \'\', CONCAT(\'【\', rtrim(a.Add_gxmc), \'】\')))';
|
|
|
}
|
|
|
|
|
|
- /** 机检、外发:不参与无形损分摊 */
|
|
|
+ /** 外发:不参与无形损分摊 */
|
|
|
private function isSuperLossIntangibleExcluded(string $gxName): bool
|
|
|
{
|
|
|
- return strpos($gxName, '机检') !== false || strpos($gxName, '外发') !== false;
|
|
|
+ return strpos($gxName, '外发') !== false;
|
|
|
}
|
|
|
|
|
|
private function isMachineInspectionProcess(string $gxName): bool
|
|
|
@@ -2327,7 +2343,7 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 机检:参与工序节损数(= 工序计划损耗),本行制程/质检/无形损不参与扣减;金额不计
|
|
|
+ * 机检:制程/质检不计入本行报废;无形损参与分摊并扣减节损数;超节损金额不计
|
|
|
*/
|
|
|
private function applyMachineInspectionProcessLossRules(string $gxName, int $planLoss, array &$row): void
|
|
|
{
|
|
|
@@ -2340,20 +2356,71 @@ class OrderSuperLoss extends Api
|
|
|
if (array_key_exists('waste_quality', $row)) {
|
|
|
$row['waste_quality'] = 0;
|
|
|
}
|
|
|
- if (array_key_exists('Gy0_无形损', $row)) {
|
|
|
- $row['Gy0_无形损'] = 0;
|
|
|
- }
|
|
|
- if (array_key_exists('intangible_loss', $row)) {
|
|
|
- $row['intangible_loss'] = 0;
|
|
|
- }
|
|
|
- $row['total_waste'] = 0;
|
|
|
- $row['loss'] = $planLoss;
|
|
|
+ $intangible = (int)($row['Gy0_无形损'] ?? $row['intangible_loss'] ?? 0);
|
|
|
+ $row['total_waste'] = $intangible;
|
|
|
+ $row['loss'] = $planLoss - $intangible;
|
|
|
}
|
|
|
|
|
|
- /** 机检、外发:不计超节损金额(机检仍计节损数;外发计节损数含制程废) */
|
|
|
+ /** 机检、外发:不计超节损金额 */
|
|
|
private function isSuperLossRewardExcluded(string $gxName): bool
|
|
|
{
|
|
|
- return $this->isSuperLossIntangibleExcluded($gxName);
|
|
|
+ return $this->isMachineInspectionProcess($gxName) || $this->isSuperLossIntangibleExcluded($gxName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 全工序计划损耗合计(含机检),用于机检无形损分摊分母 */
|
|
|
+ private function getIntangiblePlanLossTotalAll(string $gdbh, string $yjno, array $gxhValues): float
|
|
|
+ {
|
|
|
+ if (empty($gxhValues)) {
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return floatval(db('工单_工艺资料')
|
|
|
+ ->where(['Gy0_gdbh' => $gdbh, 'Gy0_yjno' => $yjno, 'Gy0_gxh' => ['in', $gxhValues]])
|
|
|
+ ->value('SUM(Gy0_计划损耗 * Gy0_ls * Gy0_ks)'));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 仅 db_sczl 报工、无产量计酬时,从最新一条报工补班组编号/分配比例(拆片等)
|
|
|
+ */
|
|
|
+ private function fillSczlTeamMemberFields(array &$row, string $gdbh, string $yjno): void
|
|
|
+ {
|
|
|
+ if (!empty($row['sczl_bh1'])) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $gxh = $row['Gy0_gxh'] ?? '';
|
|
|
+ if ($gxh === '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $sczl = db('db_sczl')
|
|
|
+ ->where('sczl_gdbh', $gdbh)
|
|
|
+ ->where('sczl_yjno', $yjno)
|
|
|
+ ->where('sczl_gxh', $gxh)
|
|
|
+ ->order('sczl_rq desc')
|
|
|
+ ->find();
|
|
|
+ if (empty($sczl)) {
|
|
|
+ $sczl = db('db_sczl')
|
|
|
+ ->where('sczl_gdbh', $gdbh)
|
|
|
+ ->where('sczl_yjno', $yjno)
|
|
|
+ ->where('sczl_gxh', (int)$gxh)
|
|
|
+ ->order('sczl_rq desc')
|
|
|
+ ->find();
|
|
|
+ }
|
|
|
+ if (empty($sczl)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for ($j = 1; $j <= 10; $j++) {
|
|
|
+ $bhKey = 'sczl_bh' . $j;
|
|
|
+ $rateKey = 'sczl_rate' . $j;
|
|
|
+ if (!empty($sczl[$bhKey])) {
|
|
|
+ $row[$bhKey] = $sczl[$bhKey];
|
|
|
+ }
|
|
|
+ if (isset($sczl[$rateKey]) && $sczl[$rateKey] !== '') {
|
|
|
+ $row[$rateKey] = $sczl[$rateKey];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($sczl['sczl_bzdh'])) {
|
|
|
+ $row['sczl_bzdh'] = $sczl['sczl_bzdh'];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2575,9 +2642,10 @@ class OrderSuperLoss extends Api
|
|
|
float $teamPlanLoss,
|
|
|
float $processPlanLoss,
|
|
|
float $intangiblePlanTotal,
|
|
|
- float $intangibleLoss
|
|
|
+ float $intangibleLoss,
|
|
|
+ float $intangiblePlanTotalAll = 0.0
|
|
|
): int {
|
|
|
- if ($intangiblePlanTotal <= 0 || $intangibleLoss == 0.0) {
|
|
|
+ if ($intangibleLoss == 0.0) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -2586,6 +2654,19 @@ class OrderSuperLoss extends Api
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ if ($this->isMachineInspectionProcess($gxName)) {
|
|
|
+ $denom = $intangiblePlanTotalAll > 0 ? $intangiblePlanTotalAll : $intangiblePlanTotal;
|
|
|
+ if ($denom <= 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (int)round($processPlanLoss / $denom * $intangibleLoss);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($intangiblePlanTotal <= 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
$planBase = $teamPlanLoss > 0 ? $teamPlanLoss : $processPlanLoss;
|
|
|
$ratio = $planBase / $intangiblePlanTotal;
|
|
|
$share = $ratio * $intangibleLoss;
|
|
|
@@ -2652,6 +2733,7 @@ class OrderSuperLoss extends Api
|
|
|
$item['sczl_bh' . $j] = '';
|
|
|
$item['sczl_rate' . $j] = 0;
|
|
|
}
|
|
|
+ $this->fillSczlTeamMemberFields($item, $gdbh, $yjno);
|
|
|
$gyData[] = $item;
|
|
|
}
|
|
|
|