|
|
@@ -141,8 +141,8 @@ class OrderSuperLoss extends Api
|
|
|
->where('d.仓库编号','Y101')
|
|
|
->whereRaw('LEFT(a.成品编码, ' . $num . ') = "' . $params['code'] . '"')
|
|
|
->field('DISTINCT(a.jjcp_gdbh) as Gd_gdbh,a.jjcp_yjno,rtrim(a.jjcp_cpdh) as 成品编码,rtrim(a.jjcp_cpmc) as 成品名称,a.jjcp_sj,a.jjcp_smb,b.计量单位,
|
|
|
- b.Gd_khdh, d.st_sl as 实际投料 ,c.yj_Yjno, c.yj_ls,c.yj_ks')
|
|
|
- ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_yjno')
|
|
|
+ b.Gd_khdh, SUM(d.st_sl) as 实际投料 ,c.yj_Yjno, c.yj_ls,c.yj_ks')
|
|
|
+ ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_yjno,d.st_rq desc')
|
|
|
->group('a.jjcp_gdbh,a.jjcp_yjno')
|
|
|
->page($pages)
|
|
|
->limit($limit)
|
|
|
@@ -161,8 +161,8 @@ class OrderSuperLoss extends Api
|
|
|
->where($where)
|
|
|
->where('d.仓库编号','Y101')
|
|
|
->field('DISTINCT(a.jjcp_gdbh) as Gd_gdbh,a.jjcp_yjno,rtrim(a.jjcp_cpdh) as 成品编码,rtrim(a.jjcp_cpmc) as 成品名称,a.jjcp_sj,a.jjcp_smb,b.计量单位,
|
|
|
- b.Gd_khdh, d.st_sl as 实际投料,c.yj_Yjno, c.yj_ls,c.yj_ks')
|
|
|
- ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_yjno')
|
|
|
+ b.Gd_khdh, SUM(d.st_sl) as 实际投料,c.yj_Yjno, c.yj_ls,c.yj_ks')
|
|
|
+ ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_yjno,d.st_rq desc')
|
|
|
->group('a.jjcp_gdbh,a.jjcp_yjno')
|
|
|
->page($pages)
|
|
|
->limit($limit)
|
|
|
@@ -202,7 +202,7 @@ class OrderSuperLoss extends Api
|
|
|
// $machine_plan_loss = $v['Gy0_计划损耗'];
|
|
|
// }
|
|
|
}
|
|
|
- if ($value['yj_ls'] > 0){
|
|
|
+ if ((int)$value['yj_ls'] > 0){
|
|
|
$value['实际投料'] = number_format(((int)$value['实际投料']/10000)*$value['yj_ls']*$value['yj_ks'],4);
|
|
|
}else{
|
|
|
$value['实际投料'] = number_format($value['实际投料']/10000,4);
|
|
|
@@ -365,10 +365,26 @@ class OrderSuperLoss extends Api
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$order = $params['order'];
|
|
|
- $field = 'Gd_gdbh,rtrim(成品代号) as 成品代号,rtrim(成品名称) as 成品名称,rtrim(销售订单号) as 销售订单号,订单数量,实际投料';
|
|
|
- $data =db('工单_基本资料')->where('Gd_Gdbh',$order)->where('行号',1)->field($field)->find();
|
|
|
+ $field = 'a.Gd_gdbh,rtrim(a.成品代号) as 成品代号,rtrim(a.成品名称) as 成品名称,rtrim(a.销售订单号) as 销售订单号,a.订单数量,c.yj_ls as ls,c.yj_ks as ks,SUM(b.st_sl) as 投料';
|
|
|
+ $data =db('工单_基本资料')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('物料_收发记录 b','a.Gd_gdbh = b.st_gdbh AND a.Gd_cpdh = b.cpdh')
|
|
|
+ ->join('工单_印件资料 c','c.Yj_Gdbh = a.Gd_gdbh AND c.yj_Yjdh = a.Gd_cpdh')
|
|
|
+ ->where('a.Gd_Gdbh',$order)
|
|
|
+ ->where('a.行号',$params['yjno'])
|
|
|
+ ->where('c.yj_Yjno',$params['yjno'])
|
|
|
+ ->where('b.仓库编号','Y101')
|
|
|
+ ->field($field)
|
|
|
+ ->find();
|
|
|
+ if ($data['ls'] == 0){
|
|
|
+ $data['ls'] === 1;
|
|
|
+ }
|
|
|
+ if ($data['ks'] == 0){
|
|
|
+ $data['ks'] === 1;
|
|
|
+ }
|
|
|
+ $data['实际投料'] = number_format($data['投料']*$data['ls']*$data['ks']/10000,4);
|
|
|
//查出成品数量及日期
|
|
|
- $cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$order}' GROUP BY jjcp_gdbh";
|
|
|
+ $cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$order}' AND jjcp_yjno = '{$params['yjno']}' GROUP BY jjcp_gdbh,jjcp_yjno";
|
|
|
$cp_data = Db::query($cp_sql);
|
|
|
if (empty($cp_data)){
|
|
|
$this->success('此工单未查询到成品入库信息,请核查该工单是否已进入超节损');
|
|
|
@@ -376,24 +392,35 @@ 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}'
|
|
|
- UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$order}') AS combined_result";
|
|
|
- $gxh_arr = Db::query($gxh_sql);
|
|
|
+// $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){
|
|
|
+ $gxh_values[$k] = '0'.$v;
|
|
|
+ }
|
|
|
+ }
|
|
|
$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_ls', 'a.Gy0_计划接货数',
|
|
|
+ '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_gxh = b.sczl_gxh','left')
|
|
|
- ->join('db_sczl c', 'a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_gxh = c.sczl_gxh','left')
|
|
|
+ ->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' => $order,
|
|
|
+ 'a.Gy0_yjno' => $params['yjno'],
|
|
|
'a.Gy0_gxh' => ['in', $gxh_values]
|
|
|
])
|
|
|
- ->group('a.Gy0_gxh')
|
|
|
+ ->group('a.Gy0_yjno,a.Gy0_gxh')
|
|
|
->select();
|
|
|
$arr = [];
|
|
|
$plan_loss = [];//工单计划损耗
|
|
|
@@ -407,13 +434,13 @@ class OrderSuperLoss extends Api
|
|
|
$real_rate = $cp_data[0]['cp_sl'] / ($data['实际投料'] * 10000) *100;
|
|
|
$data['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
|
|
|
//制程废品
|
|
|
- $zzfp_data =db('设备_产量计酬')->where('sczl_gdbh',$order)->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
|
|
|
+ $zzfp_data =db('设备_产量计酬')->where('sczl_gdbh',$order)->where('sczl_yjno',$params['yjno'])->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
|
|
|
//联数
|
|
|
- $ls =db('工单_工艺资料')->where('Gy0_gdbh',$order)->field('Gy0_ls')->find();
|
|
|
+ $ls =db('工单_工艺资料')->where('Gy0_gdbh',$order)->field('Gy0_ls,Gy0_ks')->find();
|
|
|
//制程废品*ls
|
|
|
- $data['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $ls['Gy0_ls'];
|
|
|
+ $data['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $ls['Gy0_ls'] * $ls['Gy0_ks'];
|
|
|
//废品数量
|
|
|
- $wasteTotal = db('db_qczl')->where('qczl_gdbh',$order)->sum('qczl_fp');
|
|
|
+ $wasteTotal = db('db_qczl')->where('qczl_gdbh',$order)->where('qczl_yjno',$params['yjno'])->sum('qczl_fp');
|
|
|
if (empty($wasteTotal)){
|
|
|
$wasteTotal = 0;
|
|
|
}
|
|
|
@@ -425,7 +452,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 = '{$order}'";
|
|
|
+ FROM db_qczl WHERE qczl_gdbh = '{$order}' AND qczl_yjno = '{$params['yjno']}'";
|
|
|
$waste_out = Db::query($out_sql);
|
|
|
$list = []; //外发废数组
|
|
|
$quality = [];//质检废数组
|
|
|
@@ -442,7 +469,7 @@ class OrderSuperLoss extends Api
|
|
|
$gxmcKey = "fp_gxmc" . $i;
|
|
|
$slKey = "fp_sl" . $i;
|
|
|
if (!empty($entry[$labelKey])) {
|
|
|
- if (substr($entry[$gxmcKey],0,2) == '99'){
|
|
|
+ if (substr($entry[$labelKey],0,3) == 'M04'){
|
|
|
$list[$j]= $entry[$slKey];
|
|
|
$j++;
|
|
|
}
|
|
|
@@ -450,17 +477,17 @@ 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){
|
|
|
+// if (!empty($entry[$bhKey])) {
|
|
|
+// if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
|
$quality[$m]= $entry[$slKey];
|
|
|
$m++;
|
|
|
- }
|
|
|
- }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -469,7 +496,7 @@ class OrderSuperLoss extends Api
|
|
|
$data['外发废'] = array_sum($list);//外发废
|
|
|
$data['工单质检废'] = array_sum($quality);//质检废
|
|
|
// $data['分摊废'] = '';//分摊废
|
|
|
- $plan_total =db('工单_工艺资料')->where(['Gy0_gdbh' => $order, '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_计划损耗)');
|
|
|
//单据列表最后统计
|
|
|
$total = [];
|
|
|
$total['plan_loss'] = 0;
|
|
|
@@ -482,6 +509,7 @@ class OrderSuperLoss extends Api
|
|
|
$total['total_waste'] = 0;
|
|
|
$total['loss'] = 0;
|
|
|
foreach ($gy_data as $k=>$item){
|
|
|
+ $gy_data[$k]['Gy0_计划损耗'] = $item['Gy0_计划损耗']*$item['Gy0_ls']*$item['Gy0_ks'];
|
|
|
$gy_data[$k]['waste_quality'] = 0;
|
|
|
$gy_data[$k]['total_fp'] = $item['total_fp'] * $item['Gy0_ls'];
|
|
|
$gy_data[$k]['total_cl'] = $item['total_cl'] * $item['Gy0_ls'];
|
|
|
@@ -504,7 +532,7 @@ class OrderSuperLoss extends Api
|
|
|
$gy_data[$k]['total_waste'] = $gy_data[$k]['waste_quality'] + $gy_data[$k]['intangible_loss'] + $gy_data[$k]['total_fp'];
|
|
|
}
|
|
|
//工序节损数
|
|
|
- $gy_data[$k]['loss'] = $item['Gy0_计划损耗'] - $gy_data[$k]['total_waste'];
|
|
|
+ $gy_data[$k]['loss'] = $item['Gy0_计划损耗']*$item['Gy0_ls']*$item['Gy0_ks'] - $gy_data[$k]['total_waste'];
|
|
|
//占投料报废率
|
|
|
$gy_data[$k]['loss_rate'] = number_format($gy_data[$k]['loss'] / $item['Gy0_计划接货数'],4) * 100 .'%';
|
|
|
//工序目标报废率
|
|
|
@@ -543,10 +571,11 @@ class OrderSuperLoss extends Api
|
|
|
//总产量数据
|
|
|
$total_cl_data = \db('工单_工艺资料')->alias('a')
|
|
|
->field(['a.Gy0_yjno', 'a.Gy0_gxh','a.Gy0_ls', 'SUM(b.sczl_cl) as total_cl', 'SUM(c.sczl_cl) as cl'])
|
|
|
- ->join('设备_产量计酬 b', 'a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh','left')
|
|
|
- ->join('db_sczl c', 'a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_gxh = c.sczl_gxh','left')
|
|
|
+ ->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' => $order,
|
|
|
+ 'a.Gy0_yjno' => $params['yjno'],
|
|
|
'a.Gy0_gxh' => ['IN', $gxh_values],
|
|
|
'b.sczl_cl|c.sczl_cl' => ['>', 0]
|
|
|
])
|
|
|
@@ -563,10 +592,11 @@ class OrderSuperLoss extends Api
|
|
|
'b.sczl_bh7', 'b.sczl_bh8', 'b.sczl_bh9', 'b.sczl_bh10',
|
|
|
'rtrim(c.sczl_gxmc) as gxmc', 'SUM(c.sczl_cl) as cl', 'SUM(c.sczl_fp) as fp', 'c.sczl_bh1 as sczl_bh'
|
|
|
])
|
|
|
- ->join('设备_产量计酬 b', 'a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh','left')
|
|
|
- ->join('db_sczl c', 'a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_gxh = c.sczl_gxh','left')
|
|
|
+ ->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' => $order,
|
|
|
+ 'a.Gy0_yjno' => $params['yjno'],
|
|
|
'a.Gy0_gxh' => ['in', $gxh_values],
|
|
|
'b.sczl_cl|c.sczl_cl' => ['>', 0]
|
|
|
])
|
|
|
@@ -794,24 +824,35 @@ class OrderSuperLoss extends Api
|
|
|
$this->error('非法请求');
|
|
|
}
|
|
|
$params = Request::instance()->request();
|
|
|
- if (empty($params['year']) || empty($params['month'])) {
|
|
|
+ if (empty($params['workorder']) || empty($params['yjno'])) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $search = $params['year'].'.'.$params['month'];
|
|
|
- $field = "a.Gd_gdbh,rtrim(c.yj_yjdh) as yj_yjdh,c.yj_Yjno, c.yj_ks,c.yj_ls,rtrim(c.yj_zzdh) as yj_zzdh,
|
|
|
- rtrim(b.BOM_物料名称) as BOM_物料名称,rtrim(c.yj_tlgg) as yj_tlgg,rtrim(b.BOM_投料单位) as BOM_投料单位,a.订单数量,c.yj_平张投料, b.BOM_实际用量,a.实际投料,a.投料确认,a.UniqId";
|
|
|
+// $search = $params['year'].'.'.$params['month'];
|
|
|
+ $field = "a.Gd_gdbh,rtrim(c.yj_Yjdh) as yj_yjdh,c.yj_Yjno, c.yj_ks,c.yj_ls,rtrim(c.yj_zzdh) as yj_zzdh,
|
|
|
+ rtrim(b.BOM_物料名称) as BOM_物料名称,rtrim(c.yj_tlgg) as yj_tlgg,rtrim(b.BOM_投料单位) as BOM_投料单位,
|
|
|
+ a.订单数量,c.yj_平张投料, b.BOM_实际用量,d.st_sl as 实际投料,a.投料确认,d.Uniqid as UniqId";
|
|
|
$data =db('工单_基本资料')->alias('a')
|
|
|
- ->join('工单_印件资料 c','a.Gd_gdbh = c.Yj_Gdbh','left')
|
|
|
+ ->join('工单_印件资料 c','a.Gd_gdbh = c.Yj_Gdbh ','left')
|
|
|
->join('工单_bom资料 b','c.Yj_Gdbh = b.BOM_工单编号 AND c.yj_zzdh = b.BOM_物料编码','left')
|
|
|
- ->where('a.投料确认','like','%'.$search.'%')
|
|
|
+ ->join('物料_收发记录 d','a.Gd_gdbh = d.st_gdbh AND d.cpdh = c.yj_Yjdh')
|
|
|
+// ->where('a.投料确认','like','%'.$search.'%')
|
|
|
+ ->where('a.Gd_gdbh',$params['workorder'])
|
|
|
+ ->where('c.yj_Yjno',$params['yjno'])
|
|
|
+ ->where('d.仓库编号','Y101')
|
|
|
->field($field)
|
|
|
- ->group('a.Gd_gdbh')
|
|
|
+ ->group('a.Gd_gdbh,d.Uniqid')
|
|
|
->order('b.BOM_投料单位,a.UniqId asc')
|
|
|
->select();
|
|
|
if (empty($data)){
|
|
|
$this->success('请求成功');
|
|
|
}
|
|
|
foreach ($data as $key=>$value){
|
|
|
+// if ($value['yj_ls'] > 0){
|
|
|
+// $value['实际投料'] = number_format(((int)$value['实际投料']/10000)*$value['yj_ls']*$value['yj_ks'],4);
|
|
|
+// }else{
|
|
|
+// $value['实际投料'] = number_format($value['实际投料']/10000,4);
|
|
|
+// }
|
|
|
+// $data[$key]['实际投料'] = $value['实际投料'];
|
|
|
$len = stripos($value['yj_tlgg'],'/');
|
|
|
if ($len){
|
|
|
$name = substr($value['yj_tlgg'],0,$len);
|
|
|
@@ -840,19 +881,39 @@ class OrderSuperLoss extends Api
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$i = 0;
|
|
|
+ $list = \db('物料_收发记录')->where('Uniqid',$params['0']['UniqId'])->find();
|
|
|
foreach ($params as $key=>$value){
|
|
|
if (!empty($value['number'])){
|
|
|
- $info = db('工单_基本资料')->where('UniqId',$value['UniqId'])->value('Gd_gdbh');
|
|
|
- $res_sql = db('工单_基本资料')->where('UniqId',$value['UniqId'])->fetchSql(true)->setField('实际投料',$value['number']);
|
|
|
- $res = Db::query($res_sql);
|
|
|
- $data['yj_实际投料'] = $value['number'];
|
|
|
- $yj_sql =db('工单_印件资料')->where('Yj_Gdbh',$info)->fetchSql(true)->update($data);
|
|
|
- $yjRes = Db::query($yj_sql);
|
|
|
- if (!$res && !$yjRes){
|
|
|
+ $tl_sql = \db('物料_收发记录')
|
|
|
+ ->where('Uniqid',$value['UniqId'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update(['st_sl'=>$value['number']]);
|
|
|
+ $tlRes = Db::query($tl_sql);
|
|
|
+ if (!$tlRes){
|
|
|
$i++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ $total_num = \db('物料_收发记录')
|
|
|
+ ->alias('a')
|
|
|
+ ->field('SUM(a.st_sl) as 投料数量,b.yj_ls,b.yj_ks')
|
|
|
+ ->join('工单_印件资料 b','a.st_gdbh = b.Yj_Gdbh AND a.cpdh = b.yj_yjdh')
|
|
|
+ ->where('a.st_gdbh',$list['st_gdbh'])
|
|
|
+ ->where('a.cpdh',$list['cpdh'])
|
|
|
+ ->where('a.仓库编号','Y101')
|
|
|
+ ->find();
|
|
|
+ $number = $total_num['投料数量']/10000*$total_num['yj_ls']*$total_num['yj_ks'];
|
|
|
+ $res_sql = db('工单_基本资料')->where('Gd_gdbh',$list['st_gdbh'])->where('Gd_cpdh',$list['cpdh'])->fetchSql(true)->setField('实际投料',$number);
|
|
|
+ $res = Db::query($res_sql);
|
|
|
+ $data['yj_实际投料'] = $number;
|
|
|
+ $yj_sql =db('工单_印件资料')->where('Yj_Gdbh',$list['st_gdbh'])->where('yj_Yjdh',$list['cpdh'])->fetchSql(true)->update($data);
|
|
|
+ $yjRes = Db::query($yj_sql);
|
|
|
+// if ((int)$list['yj_ls'] !== 0 && (int)$list['yj_ks'] !== 0){
|
|
|
+// $tl_num = number_format(((float)$value['number']*10000)/((int)$list['yj_ks']*(int)$list['yj_ls']),4);
|
|
|
+// }else{
|
|
|
+// $tl_num = (float)$value['number']*10000;
|
|
|
+// }
|
|
|
+// $tl_num = (float)str_replace(',', '', $tl_num);
|
|
|
if ($i != 0){
|
|
|
$this->success('更新成功');
|
|
|
}else{
|