|
|
@@ -818,7 +818,8 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
|
// $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.投料确认,c.Uniqid as UniqId";
|
|
|
+ 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('工单_bom资料 b','c.Yj_Gdbh = b.BOM_工单编号 AND c.yj_zzdh = b.BOM_物料编码','left')
|
|
|
@@ -826,20 +827,21 @@ class OrderSuperLoss extends Api
|
|
|
// ->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['实际投料'];
|
|
|
+// 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);
|
|
|
@@ -868,32 +870,39 @@ class OrderSuperLoss extends Api
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$i = 0;
|
|
|
+ $list = \db('物料_收发记录')->where('Uniqid',$params['0']['UniqId'])->find();
|
|
|
foreach ($params as $key=>$value){
|
|
|
- $list = \db('工单_印件资料')->where('Uniqid',$value['UniqId'])->find();
|
|
|
if (!empty($value['number'])){
|
|
|
- $res_sql = db('工单_基本资料')->where('Gd_gdbh',$list['Yj_Gdbh'])->where('Gd_cpdh',$list['yj_Yjdh'])->fetchSql(true)->setField('实际投料',$value['number']);
|
|
|
- $res = Db::query($res_sql);
|
|
|
- $data['yj_实际投料'] = $value['number'];
|
|
|
- $yj_sql =db('工单_印件资料')->where('Uniqid',$value['UniqId'])->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);
|
|
|
$tl_sql = \db('物料_收发记录')
|
|
|
- ->where('st_gdbh',$list['Yj_Gdbh'])
|
|
|
- ->where('cpdh',$list['yj_Yjdh'])
|
|
|
- ->where('仓库编号','Y101')
|
|
|
+ ->where('Uniqid',$value['UniqId'])
|
|
|
->fetchSql(true)
|
|
|
- ->update(['st_sl'=>$tl_num]);
|
|
|
+ ->update(['st_sl'=>$value['number']]);
|
|
|
$tlRes = Db::query($tl_sql);
|
|
|
- if (!$res && !$yjRes && !$tlRes){
|
|
|
+ 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{
|