|
@@ -31,54 +31,50 @@ class OrderSuperLoss extends Api
|
|
|
if (Request::instance()->isGet() == false) {
|
|
if (Request::instance()->isGet() == false) {
|
|
|
$this->error('非法请求');
|
|
$this->error('非法请求');
|
|
|
}
|
|
}
|
|
|
- $is_hav_cache = Cache::get('OrderSuperLoss/getTab');
|
|
|
|
|
- if ($is_hav_cache === false){
|
|
|
|
|
- $sql = "SELECT DISTINCT(Gd_gdbh),`年月`,rtrim(`客户编号`) as 客户编号,rtrim(`客户名称`) as 客户名称 FROM `rec_月度废品汇总`
|
|
|
|
|
- WHERE STR_TO_DATE(`年月`, '%Y%m') >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) order by 年月 desc,客户编号 asc";
|
|
|
|
|
- $data = Db::query($sql);
|
|
|
|
|
- $outputArray = [];
|
|
|
|
|
- foreach ($data as $item) {
|
|
|
|
|
- $yearMonth = $item['年月'];
|
|
|
|
|
- if (!isset($outputArray[$yearMonth])) {
|
|
|
|
|
- // If key doesn't exist in output array, initialize it
|
|
|
|
|
- $outputArray[$yearMonth] = [];
|
|
|
|
|
- }
|
|
|
|
|
- // Check if the customer already exists in the current yearMonth array
|
|
|
|
|
- $existingCustomerIndex = null;
|
|
|
|
|
- foreach ($outputArray[$yearMonth] as $index => $customer) {
|
|
|
|
|
- if ($customer['客户编号'] === $item['客户编号']) {
|
|
|
|
|
- $existingCustomerIndex = $index;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($existingCustomerIndex !== null) {
|
|
|
|
|
- // If customer exists, increment the total
|
|
|
|
|
- $outputArray[$yearMonth][$existingCustomerIndex]['total']++;
|
|
|
|
|
- } else {
|
|
|
|
|
- // If customer doesn't exist, add a new entry
|
|
|
|
|
- $outputArray[$yearMonth][] = [
|
|
|
|
|
- '客户名称' => $item['客户名称'],
|
|
|
|
|
- '客户编号' => $item['客户编号'],
|
|
|
|
|
- 'total' => 1,
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 遍历每个年月的数组
|
|
|
|
|
- $list = [];
|
|
|
|
|
- foreach ($outputArray as $yearMonth => $orders) {
|
|
|
|
|
- $totalOrders = 0;
|
|
|
|
|
- // 遍历每个订单,累加订单数量
|
|
|
|
|
- foreach ($orders as $order) {
|
|
|
|
|
- $totalOrders += $order['total'];
|
|
|
|
|
- }
|
|
|
|
|
- // 输出每个年月的订单数量
|
|
|
|
|
- $list[$yearMonth.'-'.$totalOrders] = $orders;
|
|
|
|
|
|
|
+ $sql = "SELECT LEFT(a.jjcp_sj, 7) AS date,RTRIM(b.`编号`) AS 编号,RTRIM(b.`名称`) as 客户名称,COUNT(DISTINCT a.jjcp_gdbh) AS count
|
|
|
|
|
+ FROM `成品入仓` a LEFT JOIN `物料_存货结构` b ON LEFT(a.`成品编码`, 4) = RTRIM(b.`编号`)
|
|
|
|
|
+ WHERE LEFT(a.jjcp_sj, 7) >= LEFT(DATE_SUB(CURDATE(), INTERVAL 12 MONTH), 7) AND a.jjcp_smb = '末 板' AND a.`成品编码` != ''
|
|
|
|
|
+ GROUP BY LEFT(a.jjcp_sj, 7), RTRIM(b.`编号`) ORDER BY date DESC, 编号 ASC";
|
|
|
|
|
+ $data = Db::query($sql);
|
|
|
|
|
+ // 创建一个新数组来存储整理后的数据
|
|
|
|
|
+ $organizedData = [];
|
|
|
|
|
+ // 遍历原始数据
|
|
|
|
|
+ foreach ($data as $entry) {
|
|
|
|
|
+ $date = date('Ym',strtotime($entry['date']));
|
|
|
|
|
+
|
|
|
|
|
+ // 检查日期是否在已整理数据中存在
|
|
|
|
|
+ if (isset($organizedData[$date])) {
|
|
|
|
|
+ // 如果日期存在,将数据追加到该日期下
|
|
|
|
|
+ $organizedData[$date][] = [
|
|
|
|
|
+ '客户名称' => $entry['客户名称'],
|
|
|
|
|
+ '客户编号' => $entry['编号'],
|
|
|
|
|
+ 'total' => $entry['count'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 统计该日期下所有数据的总和
|
|
|
|
|
+ $organizedData[$date]['total_count'] += $entry['count'];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果日期不存在,创建新的日期项并添加数据
|
|
|
|
|
+ $organizedData[$date] = [
|
|
|
|
|
+ [
|
|
|
|
|
+ '客户名称' => $entry['客户名称'],
|
|
|
|
|
+ '客户编号' => $entry['编号'],
|
|
|
|
|
+ 'total' => $entry['count'],
|
|
|
|
|
+ ]
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 初始化该日期的总和
|
|
|
|
|
+ $organizedData[$date]['total_count'] = $entry['count'];
|
|
|
}
|
|
}
|
|
|
- Cache::set('OrderSuperLoss/getTab',$list,86400);
|
|
|
|
|
- }else{
|
|
|
|
|
- $list = Cache::get('OrderSuperLoss/getTab');
|
|
|
|
|
}
|
|
}
|
|
|
- $this->success('请求成功',$list);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 将整理后的数据调整为以日期和相加的总和为索引的格式
|
|
|
|
|
+ $finalData = [];
|
|
|
|
|
+ foreach ($organizedData as $date => $entries) {
|
|
|
|
|
+ $totalCount = $entries['total_count'];
|
|
|
|
|
+ $index = $date . '-' . $totalCount;
|
|
|
|
|
+ unset($entries['total_count']);
|
|
|
|
|
+ $finalData[$index] = $entries;
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('请求成功',$finalData);
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 获取超节损工单列表
|
|
* 获取超节损工单列表
|
|
@@ -95,27 +91,27 @@ class OrderSuperLoss extends Api
|
|
|
$this->error('非法请求');
|
|
$this->error('非法请求');
|
|
|
}
|
|
}
|
|
|
$params = Request::instance()->param();
|
|
$params = Request::instance()->param();
|
|
|
-
|
|
|
|
|
$where = [];
|
|
$where = [];
|
|
|
if (!empty($params['code'])) {
|
|
if (!empty($params['code'])) {
|
|
|
if (!empty($params['search'])) {
|
|
if (!empty($params['search'])) {
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- $where['a.客户编号' ] = $params['code'];
|
|
|
|
|
|
|
+// $where['a.成品编码'] = $params['code'];
|
|
|
}
|
|
}
|
|
|
if (!empty($params['date'])) {
|
|
if (!empty($params['date'])) {
|
|
|
if (!empty($params['search'])) {
|
|
if (!empty($params['search'])) {
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- $where['a.年月' ] = $params['date'];
|
|
|
|
|
|
|
+ $where['a.jjcp_sj' ] = array('like',$params['date'].'%');
|
|
|
}
|
|
}
|
|
|
if (!empty($params['search'])) {
|
|
if (!empty($params['search'])) {
|
|
|
if (!empty($params['date']) || !empty($params['code'])) {
|
|
if (!empty($params['date']) || !empty($params['code'])) {
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- $where['a.产品名称'] = array('like','%'.$params['search'].'%');
|
|
|
|
|
|
|
+ $where['a.成品名称'] = array('like','%'.$params['search'].'%');
|
|
|
}
|
|
}
|
|
|
$where['b.行号' ] = 1;
|
|
$where['b.行号' ] = 1;
|
|
|
|
|
+ $where['a.jjcp_smb' ] = '末 板';
|
|
|
$limit = $params['limit'];
|
|
$limit = $params['limit'];
|
|
|
if (empty($limit)){
|
|
if (empty($limit)){
|
|
|
$limit = 15;
|
|
$limit = 15;
|
|
@@ -124,25 +120,43 @@ class OrderSuperLoss extends Api
|
|
|
if (empty($pages)){
|
|
if (empty($pages)){
|
|
|
$pages = 1;
|
|
$pages = 1;
|
|
|
}
|
|
}
|
|
|
- $is_have_cache = Cache::get('OrderSuperLoss/getList'.$params['date']);
|
|
|
|
|
|
|
+ $is_have_cache = false;
|
|
|
if ($is_have_cache === false){
|
|
if ($is_have_cache === false){
|
|
|
- $data = db('rec_月度废品汇总')->alias('a')
|
|
|
|
|
- ->join('工单_基本资料 b', 'a.Gd_gdbh = b.Gd_gdbh','left')
|
|
|
|
|
- ->join('工单_印件资料 c', 'a.Gd_gdbh = c.Yj_Gdbh','left')
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->field('a.Gd_gdbh, SUM(a.废品数量) AS 废品合计, a.年月, rtrim(a.Gd_cpmc) as Gd_cpmc, a.Gd_cpdh, a.实际投料, b.计量单位, c.yj_Yjno, c.yj_ls')
|
|
|
|
|
- ->group('a.Gd_gdbh')
|
|
|
|
|
- ->order('a.Gd_cpdh asc,a.年月 desc')
|
|
|
|
|
- ->page($pages)
|
|
|
|
|
- ->limit($limit)
|
|
|
|
|
- ->select();
|
|
|
|
|
-
|
|
|
|
|
- $total = db('rec_月度废品汇总')->alias('a')
|
|
|
|
|
- ->join('工单_基本资料 b', 'a.Gd_gdbh = b.Gd_gdbh','left')
|
|
|
|
|
- ->join('工单_印件资料 c', 'a.Gd_gdbh = c.Yj_Gdbh','left')
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->count();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (isset($params['code'])){
|
|
|
|
|
+ $data = db('成品入仓')->alias('a')
|
|
|
|
|
+ ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
|
|
|
|
|
+ ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->where('LEFT(a.成品编码, 4) = '.$params['code'])
|
|
|
|
|
+ ->field('DISTINCT(a.jjcp_gdbh) as Gd_gdbh,a.jjcp_yjno,rtrim(a.成品编码) as 成品编码,rtrim(a.成品名称) as 成品名称,a.jjcp_sj,a.jjcp_smb,b.计量单位,
|
|
|
|
|
+ b.Gd_khdh, b.实际投料,c.yj_Yjno, c.yj_ls')
|
|
|
|
|
+ ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_sj desc')
|
|
|
|
|
+ ->page($pages)
|
|
|
|
|
+ ->limit($limit)
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ $total = db('成品入仓')->alias('a')
|
|
|
|
|
+ ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
|
|
|
|
|
+ ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->where('LEFT(a.成品编码,4) ='.$params['code'])
|
|
|
|
|
+ ->count();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $data = db('成品入仓')->alias('a')
|
|
|
|
|
+ ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
|
|
|
|
|
+ ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field('DISTINCT(a.jjcp_gdbh) as Gd_gdbh,a.jjcp_yjno,rtrim(a.成品编码) as 成品编码,rtrim(a.成品名称) as 成品名称,a.jjcp_sj,a.jjcp_smb,b.计量单位,
|
|
|
|
|
+ b.Gd_khdh, b.实际投料,c.yj_Yjno, c.yj_ls')
|
|
|
|
|
+ ->order('b.Gd_khdh,a.成品编码 asc,a.jjcp_sj desc')
|
|
|
|
|
+ ->page($pages)
|
|
|
|
|
+ ->limit($limit)
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ $total = db('成品入仓')->alias('a')
|
|
|
|
|
+ ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
|
|
|
|
|
+ ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->count();
|
|
|
|
|
+ }
|
|
|
foreach ($data as $key => $value){
|
|
foreach ($data as $key => $value){
|
|
|
//查出成品数量及日期
|
|
//查出成品数量及日期
|
|
|
$cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$value['Gd_gdbh']}' GROUP BY jjcp_gdbh";
|
|
$cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$value['Gd_gdbh']}' GROUP BY jjcp_gdbh";
|
|
@@ -168,30 +182,32 @@ class OrderSuperLoss extends Api
|
|
|
$real_rate = $cp_data[0]['cp_sl'] / ($value['实际投料'] * 10000) *100;
|
|
$real_rate = $cp_data[0]['cp_sl'] / ($value['实际投料'] * 10000) *100;
|
|
|
$data[$key]['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
|
|
$data[$key]['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
|
|
|
//奖惩系数及金额
|
|
//奖惩系数及金额
|
|
|
- $data[$key]['reward_rate'] = '';
|
|
|
|
|
|
|
+ $data[$key]['reward_rate'] = '1';
|
|
|
$data[$key]['reward_money'] = '';
|
|
$data[$key]['reward_money'] = '';
|
|
|
//制程废品
|
|
//制程废品
|
|
|
$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'])->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
|
|
|
$data[$key]['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $value['yj_ls'];//制程废品
|
|
$data[$key]['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $value['yj_ls'];//制程废品
|
|
|
- $data[$key]['废品合计'] = $data[$key]['zcfp'] + $value['废品合计'];//废品合计
|
|
|
|
|
- $data[$key]['intangible_loss'] = $value['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $data[$key]['废品合计'];//工单无形损
|
|
|
|
|
- //材料废
|
|
|
|
|
- $waste_l =db('rec_月度废品汇总')->where('Gd_gdbh',$value['Gd_gdbh'])->where('废品类别','like','%L%')->field('SUM(废品数量) as 废品数量')->select();
|
|
|
|
|
- $data[$key]['material_waste'] = $waste_l[0]['废品数量'];
|
|
|
|
|
- //零头处理
|
|
|
|
|
- $waste_w = db('rec_月度废品汇总')->where('Gd_gdbh',$value['Gd_gdbh'])->where('废品类别','like','%M%')->field('SUM(废品数量) as 废品数量')->select();
|
|
|
|
|
- $data[$key]['minor_processing'] = $waste_w[0]['废品数量'];
|
|
|
|
|
- //外发废
|
|
|
|
|
|
|
+ //废品合计
|
|
|
|
|
+ $wasteTotal = db('db_qczl')->where('qczl_gdbh',$value['Gd_gdbh'])->sum('qczl_fp');
|
|
|
|
|
+ if (empty($wasteTotal)){
|
|
|
|
|
+ $wasteTotal = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $data[$key]['废品合计'] = $wasteTotal + $data[$key]['zcfp'];//废品合计
|
|
|
|
|
+ $data[$key]['工单无形损'] = (int)($value['实际投料'] *10000) - $cp_data[0]['cp_sl'] - $data[$key]['废品合计'];//工单无形损
|
|
|
$out_sql = "SELECT fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
|
|
$out_sql = "SELECT fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
|
|
|
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_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_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
|
|
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']}'";
|
|
|
$waste_out = Db::query($out_sql);
|
|
$waste_out = Db::query($out_sql);
|
|
|
- $list = [];
|
|
|
|
|
- $quality = [];
|
|
|
|
|
|
|
+ $list = []; //外发废数组
|
|
|
|
|
+ $quality = [];//质检废数组
|
|
|
|
|
+ $material = [];//材料废数组
|
|
|
|
|
+ $change = [];//零头处理数组
|
|
|
$j = 0;
|
|
$j = 0;
|
|
|
$m = 0;
|
|
$m = 0;
|
|
|
|
|
+ $n = 0;
|
|
|
|
|
+ $l = 0;
|
|
|
foreach ($waste_out as $entry) {
|
|
foreach ($waste_out as $entry) {
|
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
|
$labelKey = "fp_lb" . $i;
|
|
$labelKey = "fp_lb" . $i;
|
|
@@ -203,6 +219,14 @@ class OrderSuperLoss extends Api
|
|
|
$list[$j]= $entry[$slKey];
|
|
$list[$j]= $entry[$slKey];
|
|
|
$j++;
|
|
$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 (!empty($entry[$bhKey])) {
|
|
|
if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
@@ -212,18 +236,20 @@ class OrderSuperLoss extends Api
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $data[$key]['waste_out'] = array_sum($list);//外发废
|
|
|
|
|
- $data[$key]['waste_share'] = '';//分摊废
|
|
|
|
|
- $data[$key]['plan_loss'] = array_sum($plan_loss);//工单计划损耗
|
|
|
|
|
- $data[$key]['waste_quality'] = array_sum($quality); //质检废
|
|
|
|
|
|
|
+ $data[$key]['材料废'] = array_sum($material); //材料废
|
|
|
|
|
+ $data[$key]['零头处理'] = array_sum($change); //零头处理
|
|
|
|
|
+ $data[$key]['外发废'] = array_sum($list);//外发废
|
|
|
|
|
+ $data[$key]['分摊废'] = '';//分摊废
|
|
|
|
|
+ $data[$key]['工单计划损耗'] = array_sum($plan_loss);//工单计划损耗
|
|
|
|
|
+ $data[$key]['工单质检废'] = array_sum($quality); //质检废
|
|
|
}
|
|
}
|
|
|
$res = [
|
|
$res = [
|
|
|
'data'=>$data,
|
|
'data'=>$data,
|
|
|
'total' => $total
|
|
'total' => $total
|
|
|
];
|
|
];
|
|
|
- Cache::set('OrderSuperLoss/getList'.$params['date'],$res,86400);
|
|
|
|
|
|
|
+// Cache::set('OrderSuperLoss/getList'.$params['date'],$res,3600);
|
|
|
}else{
|
|
}else{
|
|
|
- $res = Cache::get('OrderSuperLoss/getList'.$params['date']);
|
|
|
|
|
|
|
+// $res = Cache::get('OrderSuperLoss/getList'.$params['date']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->success('请求成功',$res);
|
|
$this->success('请求成功',$res);
|
|
@@ -322,28 +348,28 @@ class OrderSuperLoss extends Api
|
|
|
//制程废品*ls
|
|
//制程废品*ls
|
|
|
$data['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $ls;
|
|
$data['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $ls;
|
|
|
//废品数量
|
|
//废品数量
|
|
|
- $waste =db('rec_月度废品汇总')->where('Gd_gdbh',$order)->field('SUM(废品数量) as 废品合计')->select();
|
|
|
|
|
|
|
+ $wasteTotal = db('db_qczl')->where('qczl_gdbh',$order)->sum('qczl_fp');
|
|
|
|
|
+ if (empty($wasteTotal)){
|
|
|
|
|
+ $wasteTotal = 0;
|
|
|
|
|
+ }
|
|
|
//废品合计
|
|
//废品合计
|
|
|
- $waste_total = $data['zcfp'] + $waste[0]['废品合计'];
|
|
|
|
|
|
|
+ $waste_total = $data['zcfp'] + $wasteTotal;
|
|
|
//工单无形损
|
|
//工单无形损
|
|
|
$data['intangible_loss'] = $data['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $waste_total;
|
|
$data['intangible_loss'] = $data['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $waste_total;
|
|
|
- //材料废
|
|
|
|
|
- $waste_l =db('rec_月度废品汇总')->where('Gd_gdbh',$order)->where('废品类别','like','%L%')->field('SUM(废品数量) as 废品数量')->select();
|
|
|
|
|
- $data['material_waste'] = $waste_l[0]['废品数量'];
|
|
|
|
|
- //零头处理
|
|
|
|
|
- $waste_w = db('rec_月度废品汇总')->where('Gd_gdbh',$order)->where('废品类别','like','%M%')->field('SUM(废品数量) as 废品数量')->select();
|
|
|
|
|
- $data['minor_processing'] = $waste_w[0]['废品数量'];
|
|
|
|
|
- //外发废
|
|
|
|
|
$out_sql = "SELECT fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
|
|
$out_sql = "SELECT fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
|
|
|
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_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_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
|
|
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}'";
|
|
|
$waste_out = Db::query($out_sql);
|
|
$waste_out = Db::query($out_sql);
|
|
|
- $list = [];
|
|
|
|
|
- $quality = [];
|
|
|
|
|
|
|
+ $list = []; //外发废数组
|
|
|
|
|
+ $quality = [];//质检废数组
|
|
|
|
|
+ $material = [];//材料废数组
|
|
|
|
|
+ $change = [];//零头处理数组
|
|
|
$j = 0;
|
|
$j = 0;
|
|
|
$m = 0;
|
|
$m = 0;
|
|
|
|
|
+ $n = 0;
|
|
|
|
|
+ $l = 0;
|
|
|
foreach ($waste_out as $entry) {
|
|
foreach ($waste_out as $entry) {
|
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
for ($i = 1; $i <= 13; $i++) {
|
|
|
$labelKey = "fp_lb" . $i;
|
|
$labelKey = "fp_lb" . $i;
|
|
@@ -355,6 +381,14 @@ class OrderSuperLoss extends Api
|
|
|
$list[$j]= $entry[$slKey];
|
|
$list[$j]= $entry[$slKey];
|
|
|
$j++;
|
|
$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 (!empty($entry[$bhKey])) {
|
|
|
if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
|
|
@@ -365,9 +399,11 @@ class OrderSuperLoss extends Api
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $data['waste_out'] = array_sum($list);//外发废
|
|
|
|
|
- //质检废
|
|
|
|
|
- $data['waste_quality'] = array_sum($quality);
|
|
|
|
|
|
|
+ $data['材料废'] = array_sum($material); //材料废
|
|
|
|
|
+ $data['零头处理'] = array_sum($change); //零头处理
|
|
|
|
|
+ $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_gxh' => ['in', $gxh_values]])->value('SUM(Gy0_计划损耗)');
|
|
|
//单据列表最后统计
|
|
//单据列表最后统计
|
|
|
$total = [];
|
|
$total = [];
|
|
@@ -412,7 +448,6 @@ class OrderSuperLoss extends Api
|
|
|
$data['total'] = $total;
|
|
$data['total'] = $total;
|
|
|
$this->success('请求成功',$data);
|
|
$this->success('请求成功',$data);
|
|
|
}else{ //按班组打印
|
|
}else{ //按班组打印
|
|
|
-// halt($data);
|
|
|
|
|
//总产量数据
|
|
//总产量数据
|
|
|
$total_cl_data = \db('工单_工艺资料')->alias('a')
|
|
$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'])
|
|
->field(['a.Gy0_yjno', 'a.Gy0_gxh','a.Gy0_ls', 'SUM(b.sczl_cl) as total_cl', 'SUM(c.sczl_cl) as cl'])
|
|
@@ -425,7 +460,6 @@ class OrderSuperLoss extends Api
|
|
|
->group('b.sczl_gxh')
|
|
->group('b.sczl_gxh')
|
|
|
->order('a.Gy0_gxh')
|
|
->order('a.Gy0_gxh')
|
|
|
->select();
|
|
->select();
|
|
|
-// halt($total_cl_data);
|
|
|
|
|
//按班组分的产量数据
|
|
//按班组分的产量数据
|
|
|
$gy_data =db('工单_工艺资料')
|
|
$gy_data =db('工单_工艺资料')
|
|
|
->alias('a')
|
|
->alias('a')
|