|
|
@@ -392,15 +392,15 @@ class OrderSuperLoss extends Api
|
|
|
$data['warehousing_num'] = $cp_data[0]['cp_sl'];
|
|
|
$data['warehousing_date'] = substr($cp_data[0]['jjcp_sj'],0,10);
|
|
|
//查出进入超节损的工序,有上报产量的工序就进入超节损
|
|
|
-// $gxh_sql = "SELECT sczl_gxh FROM
|
|
|
-// (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}'
|
|
|
-// UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}') AS combined_result";
|
|
|
-// $gxh_arr = Db::query($gxh_sql);
|
|
|
- $gxh_arr = \db('工单_工艺资料')
|
|
|
- ->where('Gy0_gdbh',$order)
|
|
|
- ->where('Gy0_yjno',$params['yjno'])
|
|
|
- ->field('Gy0_gxh as sczl_gxh')
|
|
|
- ->select();
|
|
|
+ $gxh_sql = "SELECT sczl_gxh FROM
|
|
|
+ (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}'
|
|
|
+ UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}') AS combined_result";
|
|
|
+ $gxh_arr = Db::query($gxh_sql);
|
|
|
+// $gxh_arr = \db('工单_工艺资料')
|
|
|
+// ->where('Gy0_gdbh',$order)
|
|
|
+// ->where('Gy0_yjno',$params['yjno'])
|
|
|
+// ->field('Gy0_gxh as sczl_gxh')
|
|
|
+// ->select();
|
|
|
$gxh_values = array_column($gxh_arr, 'sczl_gxh');
|
|
|
foreach ($gxh_values as $k=>$v){
|
|
|
if ((int)$v < 10){
|
|
|
@@ -496,7 +496,7 @@ class OrderSuperLoss extends Api
|
|
|
$data['外发废'] = array_sum($list);//外发废
|
|
|
$data['工单质检废'] = array_sum($quality);//质检废
|
|
|
// $data['分摊废'] = '';//分摊废
|
|
|
- $plan_total =db('工单_工艺资料')->where(['Gy0_gdbh' => $order,'Gy0_yjno' => $params['yjno'], 'Gy0_gxh' => ['in', $gxh_values]])->value('SUM(Gy0_计划损耗)');
|
|
|
+ $plan_total =db('工单_工艺资料')->where(['Gy0_gdbh' => $order,'Gy0_yjno' => $params['yjno'], 'Gy0_gxh' => ['in', $gxh_values]])->value('SUM(Gy0_计划损耗 * Gy0_ls * Gy0_ks)');
|
|
|
//单据列表最后统计
|
|
|
$total = [];
|
|
|
$total['plan_loss'] = 0;
|
|
|
@@ -514,7 +514,7 @@ class OrderSuperLoss extends Api
|
|
|
$gy_data[$k]['total_fp'] = $item['total_fp'] * $item['Gy0_ls'];
|
|
|
$gy_data[$k]['total_cl'] = $item['total_cl'] * $item['Gy0_ls'];
|
|
|
//无形损
|
|
|
- $gy_data[$k]['intangible_loss'] = round(number_format($item['Gy0_计划损耗']/$plan_total,4) * $data['intangible_loss']);
|
|
|
+ $gy_data[$k]['intangible_loss'] = round(number_format($gy_data[$k]['Gy0_计划损耗']/$plan_total,4) * $data['intangible_loss']);
|
|
|
foreach ($waste_out as $entry) {
|
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
|
$gxmcKey = "fp_gxmc" . $i;
|
|
|
@@ -586,7 +586,7 @@ class OrderSuperLoss extends Api
|
|
|
$gy_data =db('工单_工艺资料')
|
|
|
->alias('a')
|
|
|
->field([
|
|
|
- 'a.Gy0_yjno', 'a.Gy0_gxh', 'a.Gy0_ls', 'a.Gy0_计划损耗', 'a.超节损承担比例', 'b.sczl_gxmc',
|
|
|
+ 'a.Gy0_yjno', 'a.Gy0_gxh', 'a.Gy0_ls', 'a.Gy0_ks' ,'a.Gy0_计划损耗', 'a.超节损承担比例', 'b.sczl_gxmc',
|
|
|
'SUM(b.sczl_zcfp) as sczl_zcfp', 'SUM(b.sczl_cl) as total_cl',
|
|
|
'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',
|
|
|
@@ -613,6 +613,8 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
|
//计算每道工序的计划损耗
|
|
|
foreach ($total_cl_data as $k=>$v){
|
|
|
+ $value['Gy0_计划损耗'] = $value['Gy0_计划损耗']*$value['Gy0_ls']*$value['Gy0_ks'];
|
|
|
+ var_dump($value['Gy0_计划损耗']);
|
|
|
//每道工序的总产量
|
|
|
$cl = $v['total_cl'] * $v['Gy0_ls'];
|
|
|
if (empty($cl)){
|