|
|
@@ -112,7 +112,7 @@ class OrderSuperLoss extends Api
|
|
|
if (!empty($params['date']) || !empty($params['code'])) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $where['a.成品名称|a.jjcp_gdbh'] = array('like','%'.$params['search'].'%');
|
|
|
+ $where['a.jjcp_gdbh'] = array('like','%'.$params['search'].'%');
|
|
|
}
|
|
|
$where['b.行号' ] = 1;
|
|
|
$where['a.jjcp_smb' ] = array('IN', array('末 板', '末板'));
|
|
|
@@ -181,11 +181,31 @@ class OrderSuperLoss extends Api
|
|
|
$data[$key]['warehousing_date'] = substr($cp_data[0]['jjcp_sj'],0,10);
|
|
|
//查出进入超节损的工序,有上报产量的工序就进入超节损
|
|
|
$gxh_sql = "SELECT sczl_gxh FROM
|
|
|
- (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$value['Gd_gdbh']}'
|
|
|
- UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$value['Gd_gdbh']}') AS combined_result";
|
|
|
+ (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$value['Gd_gdbh']}' AND sczl_yjno = '{$value['jjcp_yjno']}'
|
|
|
+ UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$value['Gd_gdbh']}' AND sczl_yjno = '{$value['jjcp_yjno']}') AS combined_result";
|
|
|
$gxh_arr = Db::query($gxh_sql);
|
|
|
$gxh_values = array_column($gxh_arr, 'sczl_gxh');
|
|
|
- $gy_data =db('工单_工艺资料')->where('Gy0_gdbh',$value['Gd_gdbh'])->where('Gy0_gxh','in',$gxh_values)->field('Gy0_gxmc,Gy0_计划接货数,Gy0_计划损耗')->select();
|
|
|
+// $gy_data =db('工单_工艺资料')
|
|
|
+// ->where('Gy0_gdbh',$value['Gd_gdbh'])
|
|
|
+// ->where('Gy0_yjno',$value['jjcp_yjno'])
|
|
|
+// ->where('Gy0_gxh','in',$gxh_values)
|
|
|
+// ->field('Gy0_gxmc,Gy0_计划接货数,Gy0_计划损耗')
|
|
|
+// ->select();
|
|
|
+ $gy_data =db('工单_工艺资料')
|
|
|
+ ->alias('a')
|
|
|
+ ->field([
|
|
|
+ 'a.Gy0_yjno', 'a.Gy0_gxh', 'RTRIM(a.Gy0_gxmc) as Gy0_gxmc','RTRIM(a.Add_gxmc) as Add_gxmc','a.Gy0_ks', 'a.Gy0_ls', 'a.Gy0_计划接货数',
|
|
|
+ 'a.Gy0_计划损耗', 'a.超节损承担比例','SUM(b.sczl_zcfp) as total_fp','SUM(b.sczl_cl) as total_cl','SUM(c.sczl_cl) as cl','SUM(c.sczl_fp) as fp',
|
|
|
+ ])
|
|
|
+ ->join('设备_产量计酬 b', 'a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_yjno = b.sczl_yjno AND a.Gy0_gxh = b.sczl_gxh','left')
|
|
|
+ ->join('db_sczl c', 'a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_yjno = c.sczl_yjno AND a.Gy0_gxh = c.sczl_gxh','left')
|
|
|
+ ->where([
|
|
|
+ 'a.Gy0_gdbh' => $value['Gd_gdbh'],
|
|
|
+ 'a.Gy0_yjno' =>$value['jjcp_yjno'],
|
|
|
+ 'a.Gy0_gxh' => ['in', $gxh_values]
|
|
|
+ ])
|
|
|
+ ->group('a.Gy0_yjno,a.Gy0_gxh')
|
|
|
+ ->select();
|
|
|
$arr = [];
|
|
|
$plan_loss = [];//工单计划损耗
|
|
|
$machine_plan_loss = 0;//机检计划损耗
|
|
|
@@ -218,10 +238,10 @@ class OrderSuperLoss extends Api
|
|
|
$data[$key]['real_rate'] = '';//实际合格率
|
|
|
}
|
|
|
//制程废品
|
|
|
- $zzfp_data =db('设备_产量计酬')->where('sczl_gdbh',$value['Gd_gdbh'])->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
|
|
|
+ $zzfp_data =db('设备_产量计酬')->where('sczl_gdbh',$value['Gd_gdbh'])->where('sczl_yjno',$value['jjcp_yjno'])->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
|
|
|
$data[$key]['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $value['yj_ls'];//制程废品
|
|
|
//废品合计
|
|
|
- $wasteTotal = db('db_qczl')->where('qczl_gdbh',$value['Gd_gdbh'])->sum('qczl_fp');
|
|
|
+ $wasteTotal = db('db_qczl')->where('qczl_gdbh',$value['Gd_gdbh'])->where('qczl_yjno',$value['jjcp_yjno'])->sum('qczl_fp');
|
|
|
if (empty($wasteTotal)){
|
|
|
$wasteTotal = 0;
|
|
|
}
|
|
|
@@ -231,7 +251,7 @@ class OrderSuperLoss extends Api
|
|
|
fp_lb1,fp_lb2,fp_lb3,fp_lb4,fp_lb5,fp_lb6,fp_lb7,fp_lb8,fp_lb9,fp_lb10,fp_lb11,fp_lb12,fp_lb13,
|
|
|
fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
|
|
|
fp_gxmc1,fp_gxmc2,fp_gxmc3,fp_gxmc4,fp_gxmc5,fp_gxmc6,fp_gxmc7,fp_gxmc8,fp_gxmc9,fp_gxmc10,fp_gxmc11,fp_gxmc12,fp_gxmc13
|
|
|
- FROM db_qczl WHERE qczl_gdbh = '{$value['Gd_gdbh']}'";
|
|
|
+ FROM db_qczl WHERE qczl_gdbh = '{$value['Gd_gdbh']}' AND qczl_yjno = '{$value['jjcp_yjno']}'";
|
|
|
$waste_out = Db::query($out_sql);
|
|
|
$list = []; //外发废数组
|
|
|
$quality = [];//质检废数组
|
|
|
@@ -249,8 +269,32 @@ class OrderSuperLoss extends Api
|
|
|
$bhKey = "fp_bh" . $i;
|
|
|
$gxmcKey = "fp_gxmc" . $i;
|
|
|
$slKey = "fp_sl" . $i;
|
|
|
+// if (!empty($entry[$labelKey])) {
|
|
|
+// if (substr($entry[$gxmcKey],0,2) == '99'){
|
|
|
+// $list[$j]= $entry[$slKey];
|
|
|
+// $j++;
|
|
|
+// }
|
|
|
+// if (substr($entry[$labelKey],0,1) == 'L' ){
|
|
|
+// $material[$n]= $entry[$slKey];
|
|
|
+// $n++;
|
|
|
+// }
|
|
|
+// if (substr($entry[$labelKey],0,3) == 'M04' ){
|
|
|
+// $change[$l]= $entry[$slKey];
|
|
|
+// $l++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (!empty($entry[$bhKey])) {
|
|
|
+// if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
|
+// $quality[$m]= $entry[$slKey];
|
|
|
+// $m++;
|
|
|
+// }
|
|
|
+//// if ($entry[$bhKey] != '000000' && substr($entry[$labelKey],0,3) == 'K01'){
|
|
|
+//// $machine[$o]= $entry[$slKey];
|
|
|
+//// $o++;
|
|
|
+//// }
|
|
|
+// }
|
|
|
if (!empty($entry[$labelKey])) {
|
|
|
- if (substr($entry[$gxmcKey],0,2) == '99'){
|
|
|
+ if (substr($entry[$labelKey],0,3) == 'M04'){
|
|
|
$list[$j]= $entry[$slKey];
|
|
|
$j++;
|
|
|
}
|
|
|
@@ -258,45 +302,43 @@ class OrderSuperLoss extends Api
|
|
|
$material[$n]= $entry[$slKey];
|
|
|
$n++;
|
|
|
}
|
|
|
- if (substr($entry[$labelKey],0,3) == 'M04' ){
|
|
|
+ if (substr($entry[$labelKey],0,3) == 'M01' ){
|
|
|
$change[$l]= $entry[$slKey];
|
|
|
$l++;
|
|
|
}
|
|
|
}
|
|
|
- if (!empty($entry[$bhKey])) {
|
|
|
- if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
|
- $quality[$m]= $entry[$slKey];
|
|
|
- $m++;
|
|
|
- }
|
|
|
-// if ($entry[$bhKey] != '000000' && substr($entry[$labelKey],0,3) == 'K01'){
|
|
|
-// $machine[$o]= $entry[$slKey];
|
|
|
-// $o++;
|
|
|
-// }
|
|
|
- }
|
|
|
+// if (!empty($entry[$bhKey])) {
|
|
|
+// if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
|
+ $quality[$m]= $entry[$slKey];
|
|
|
+ $m++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
-// $machine_waste = array_sum($machine);//机检废品
|
|
|
-// if ($data[$key]['Gd_gdbh'] == '2401746'){
|
|
|
-// halt($machine_waste);
|
|
|
-// }
|
|
|
-// $data[$key]['工单计划损耗'] = array_sum($plan_loss);//工单计划损耗
|
|
|
-// /**
|
|
|
-// * 奖惩系数及金额
|
|
|
-// * 奖惩金额 = 工单节损数 * 0.02(0.09)
|
|
|
-// * 工单节损数 = 工单计划损耗 - 废品总数 - 机检节损数
|
|
|
-// * 机检节损数 = 机检计划损耗 - 机检质检废品
|
|
|
-// */
|
|
|
-// $machine_loss = $machine_plan_loss - $machine_waste;
|
|
|
-// $order_loss = $data[$key]['工单计划损耗'] - $data[$key]['废品合计'] - $machine_loss;
|
|
|
-// if (strpos($data[$key]['成品名称'],'小盒')){
|
|
|
-// $moneyRate = 0.02;
|
|
|
-// }else{
|
|
|
-// $moneyRate = 0.09;
|
|
|
-// }
|
|
|
-// $reward = $order_loss * $moneyRate;
|
|
|
+ $machine_waste = array_sum($machine);//机检废品
|
|
|
+ if ($data[$key]['Gd_gdbh'] == '2401746'){
|
|
|
+ halt($machine_waste);
|
|
|
+ }
|
|
|
+ $data[$key]['工单计划损耗'] = array_sum($plan_loss);//工单计划损耗
|
|
|
+ /**
|
|
|
+ * 奖惩系数及金额
|
|
|
+ * 奖惩金额 = 工单节损数 * 0.02(0.09)
|
|
|
+ * 工单节损数 = 工单计划损耗 - 废品总数 - 机检节损数
|
|
|
+ * 机检节损数 = 机检计划损耗 - 机检质检废品
|
|
|
+ */
|
|
|
+ $machine_loss = $machine_plan_loss - $machine_waste;
|
|
|
+ $order_loss = $data[$key]['工单计划损耗'] - ($data[$key]['废品合计'] - array_sum($list));
|
|
|
+ if (strpos($data[$key]['成品名称'],'小盒')){
|
|
|
+ $moneyRate = 0.02;
|
|
|
+ }else{
|
|
|
+ $moneyRate = 0.09;
|
|
|
+ }
|
|
|
+
|
|
|
+ $reward = $order_loss * $moneyRate;
|
|
|
$data[$key]['reward_rate'] = '1';
|
|
|
-// $data[$key]['reward_money'] = number_format($reward,2);
|
|
|
- $data[$key]['reward_money'] = '';
|
|
|
+ $data[$key]['reward_money'] = number_format($reward,2);
|
|
|
+// $data[$key]['reward_money'] = '';
|
|
|
$data[$key]['材料废'] = array_sum($material); //材料废
|
|
|
$data[$key]['零头处理'] = array_sum($change); //零头处理
|
|
|
$data[$key]['外发废'] = array_sum($list);//外发废
|