|
@@ -492,9 +492,13 @@ class OrderSuperLoss extends Api
|
|
|
'a.Gy0_gdbh' => $order,
|
|
'a.Gy0_gdbh' => $order,
|
|
|
'a.Gy0_gxh' => ['in', $gxh_values]
|
|
'a.Gy0_gxh' => ['in', $gxh_values]
|
|
|
])
|
|
])
|
|
|
- ->group('b.sczl_gxh, b.sczl_bh1, b.sczl_bh2, b.sczl_bh3, b.sczl_bh4,b.sczl_bh5,b.sczl_bh6,b.sczl_bh7,b.sczl_bh8,b.sczl_bh9,b.sczl_bh10, c.sczl_bh')
|
|
|
|
|
- ->order('a.Gy0_gxh, b.UniqId DESC, c.UniqId DESC')
|
|
|
|
|
|
|
+// ->group('b.sczl_gxh,b.sczl_bh1, b.sczl_bh2, b.sczl_bh3, b.sczl_bh4,b.sczl_bh5,b.sczl_bh6,b.sczl_bh7,b.sczl_bh8,b.sczl_bh9,b.sczl_bh10, c.sczl_bh')
|
|
|
|
|
+ ->group('b.sczl_gxh, b.sczl_bh1, CASE WHEN b.sczl_bh2 = "000000" THEN "" ELSE b.sczl_bh2 END, b.sczl_bh3,
|
|
|
|
|
+ b.sczl_bh4, b.sczl_bh5, b.sczl_bh6, b.sczl_bh7, b.sczl_bh8, b.sczl_bh9, c.sczl_bh1')
|
|
|
|
|
+ ->order('a.Gy0_gxh asc, b.开工时间 asc, c.sczl_rq desc')
|
|
|
|
|
+// ->fetchSql(true)
|
|
|
->select();
|
|
->select();
|
|
|
|
|
+// halt($gy_data);
|
|
|
foreach ($gy_data as $key=>$value){
|
|
foreach ($gy_data as $key=>$value){
|
|
|
$gy_data[$key]['Gy0_yjno'] = $value['Gy0_yjno'] > 10 ? $value['Gy0_yjno'] : '0'.$value['Gy0_yjno'];
|
|
$gy_data[$key]['Gy0_yjno'] = $value['Gy0_yjno'] > 10 ? $value['Gy0_yjno'] : '0'.$value['Gy0_yjno'];
|
|
|
//每道工序的产量(按班组分)
|
|
//每道工序的产量(按班组分)
|
|
@@ -527,23 +531,22 @@ class OrderSuperLoss extends Api
|
|
|
$value['sczl_bh1'] = $value['sczl_bh'];
|
|
$value['sczl_bh1'] = $value['sczl_bh'];
|
|
|
}
|
|
}
|
|
|
$gy_data[$key]['sczl_bh1'] = $value['sczl_bh1'];
|
|
$gy_data[$key]['sczl_bh1'] = $value['sczl_bh1'];
|
|
|
- $gy_data[$key]['waste_quality'] = 0;
|
|
|
|
|
|
|
+ $gy_data[$key]['质检废'] = 0;
|
|
|
foreach ($waste_out as $entry) {
|
|
foreach ($waste_out as $entry) {
|
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
|
$gxmcKey = "fp_gxmc" . $i;
|
|
$gxmcKey = "fp_gxmc" . $i;
|
|
|
$slKey = "fp_sl" . $i;
|
|
$slKey = "fp_sl" . $i;
|
|
|
$bhKey = "fp_bh" . $i;
|
|
$bhKey = "fp_bh" . $i;
|
|
|
if ((int)substr($entry[$gxmcKey],0,2) == $value['Gy0_gxh'] && $entry[$bhKey] == $value['sczl_bh1']){
|
|
if ((int)substr($entry[$gxmcKey],0,2) == $value['Gy0_gxh'] && $entry[$bhKey] == $value['sczl_bh1']){
|
|
|
- $gy_data[$key]['waste_quality'] += $entry[$slKey];
|
|
|
|
|
|
|
+ $gy_data[$key]['质检废'] += $entry[$slKey];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//无形损分摊
|
|
//无形损分摊
|
|
|
- $gy_data[$key]['intangible_loss'] = round($gy_data[$key]['计划损耗'] / $plan_total * $data['intangible_loss']);
|
|
|
|
|
- //节损数量
|
|
|
|
|
- $total_waste = $gy_data[$key]['waste_quality'] + $gy_data[$key]['intangible_loss'] + $gy_data[$key]['sczl_zcfp'];
|
|
|
|
|
- $gy_data[$key]['loss'] = $gy_data[$key]['计划损耗'] - $total_waste;
|
|
|
|
|
|
|
+ $gy_data[$key]['无形损分摊'] = round($gy_data[$key]['计划损耗'] / $plan_total * $data['intangible_loss']);
|
|
|
|
|
+
|
|
|
$gy_data[$key]['超节损承担比例'] = number_format($value['超节损承担比例'],4) * 100 .'%';
|
|
$gy_data[$key]['超节损承担比例'] = number_format($value['超节损承担比例'],4) * 100 .'%';
|
|
|
//班组成员
|
|
//班组成员
|
|
|
$nameArr = [];
|
|
$nameArr = [];
|
|
@@ -560,10 +563,36 @@ class OrderSuperLoss extends Api
|
|
|
unset($gy_data[$key]['cl']);
|
|
unset($gy_data[$key]['cl']);
|
|
|
unset($gy_data[$key]['fp']);
|
|
unset($gy_data[$key]['fp']);
|
|
|
unset($gy_data[$key]['sczl_bh']);
|
|
unset($gy_data[$key]['sczl_bh']);
|
|
|
- $total['plan_loss'] += $gy_data[$key]['计划损耗'];
|
|
|
|
|
- $total['total_fp'] += $gy_data[$key]['sczl_zcfp'];
|
|
|
|
|
- $total['waste_quality'] += $gy_data[$key]['waste_quality'];
|
|
|
|
|
- $total['waste_intangible'] += $gy_data[$key]['intangible_loss'];
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ //重新计算多班组同组长的质检废,质检废 = 班组产量 / 总产量 * 质检废
|
|
|
|
|
+ $totals = [];
|
|
|
|
|
+ foreach ($gy_data as $item) {
|
|
|
|
|
+ $sczl_bh1 = $item['sczl_bh1'];
|
|
|
|
|
+ $total_cl = $item['total_cl'];
|
|
|
|
|
+
|
|
|
|
|
+ if (isset($totals[$sczl_bh1])) {
|
|
|
|
|
+ $totals[$sczl_bh1]['total'] += $total_cl;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $totals[$sczl_bh1] = ['total' => $total_cl, 'count' => 0];
|
|
|
|
|
+ }
|
|
|
|
|
+ $totals[$sczl_bh1]['count']++;
|
|
|
|
|
+ }
|
|
|
|
|
+ $i = 0;
|
|
|
|
|
+ foreach ($gy_data as &$item) {
|
|
|
|
|
+ $sczl_bh1 = $item['sczl_bh1'];
|
|
|
|
|
+ $total_cl = $item['total_cl'];
|
|
|
|
|
+ $item['total'] = $totals[$sczl_bh1]['total'];
|
|
|
|
|
+ if ($totals[$sczl_bh1]['count'] > 1) {
|
|
|
|
|
+ $item['质检废'] = round($total_cl / $totals[$sczl_bh1]['total'] * $item['质检废']);
|
|
|
|
|
+ }
|
|
|
|
|
+ //节损数量
|
|
|
|
|
+ $total_waste = $item['质检废'] + $item['sczl_zcfp'];
|
|
|
|
|
+ $gy_data[$i]['节损数量'] = $item['计划损耗'] - $total_waste;
|
|
|
|
|
+ $i++;
|
|
|
|
|
+ $total['plan_loss'] += $item['计划损耗'];
|
|
|
|
|
+ $total['total_fp'] += $item['sczl_zcfp'];
|
|
|
|
|
+ $total['waste_quality'] += $item['质检废'];
|
|
|
|
|
+ $total['waste_intangible'] += $item['无形损分摊'];
|
|
|
}
|
|
}
|
|
|
$data['gy_data'] = $gy_data;
|
|
$data['gy_data'] = $gy_data;
|
|
|
$data['total'] = $total;
|
|
$data['total'] = $total;
|