|
|
@@ -52,83 +52,6 @@ class Decision extends Api
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
-
|
|
|
-// public function MachineProduction()
|
|
|
-// {
|
|
|
-// if ($this->request->isGet() === false){
|
|
|
-// $this->error('请求错误');
|
|
|
-// }
|
|
|
-// $param = $this->request->param();
|
|
|
-// if (empty($param['mouth'])){
|
|
|
-// $this->error('参数错误');
|
|
|
-// }
|
|
|
-// $where = [];
|
|
|
-// if(!empty($param['sist'])){
|
|
|
-// $where['设备编组'] = $param['sist'];
|
|
|
-// }
|
|
|
-// //将参数装换成标准日期格式
|
|
|
-// $mouth = date_create_from_format('Ym', $param['mouth'])->format('Y-m');
|
|
|
-// $machine = \db('设备_基本资料')
|
|
|
-// ->where($where)
|
|
|
-// ->where('sys_sbID','<>','')
|
|
|
-// ->field('设备编号')
|
|
|
-// ->order('设备编号')
|
|
|
-// ->select();
|
|
|
-// $day = \db('设备_产量计酬')
|
|
|
-// ->distinct(true)
|
|
|
-// ->field('DATE_FORMAT(sczl_rq,"%Y-%m-%d") as day')
|
|
|
-// ->whereRaw("DATE_FORMAT(sczl_rq, '%Y-%m') = '$mouth'")
|
|
|
-// ->order('day')
|
|
|
-// ->select();
|
|
|
-// $day = array_reduce($day, function($carry, $item) {
|
|
|
-// return array_merge($carry, array_values($item));
|
|
|
-// }, []);
|
|
|
-// $data = [];
|
|
|
-// $data['head'] = $day;
|
|
|
-// foreach ($machine as $key=>$value){
|
|
|
-// $data['total'][$key] = \db('设备_产量计酬')
|
|
|
-// ->field('sczl_jtbh,sczl_bzdh,SUM(sczl_cl) as total_cl,sczl_rq')
|
|
|
-// ->where('sczl_rq','like',$mouth.'%')
|
|
|
-// ->where('sczl_jtbh',$value['设备编号'])
|
|
|
-// ->group('sczl_bzdh')
|
|
|
-// ->select();
|
|
|
-// foreach ($data['total'][$key] as $k=>$v){
|
|
|
-// $day_cl = \db('设备_产量计酬')
|
|
|
-// ->alias('a')
|
|
|
-// ->join('工单_印件资料 c','a.sczl_gdbh = c.Yj_Gdbh AND a.sczl_yjno = c.yj_Yjno')
|
|
|
-// ->join('工单_工艺资料 d','a.sczl_gdbh = d.Gy0_gdbh AND a.sczl_yjno = d.Gy0_yjno AND a.sczl_gxh = d.Gy0_gxh')
|
|
|
-// ->field([
|
|
|
-// 'a.sczl_gdbh' => '工单编号',
|
|
|
-// 'a.sczl_yjno' => '印件号',
|
|
|
-// 'a.sczl_gxh' => '工序号',
|
|
|
-// 'c.yj_yjmc' => '印件名称',
|
|
|
-// 'CONCAT(d.Gy0_gxmc,"(",d.Add_gxmc,")")' => '工序名称',
|
|
|
-// 'DATE(a.sczl_rq)' => 'day',
|
|
|
-// 'a.sczl_jtbh' => '机台编号',
|
|
|
-// 'a.sczl_bzdh' => '班组编号',
|
|
|
-// 'SUM(a.sczl_cl)' => 'total_cl',
|
|
|
-// 'a.sczl_ms' => '墨色数',
|
|
|
-// 'rtrim(d.印刷方式)' => '印刷方式',
|
|
|
-// 'rtrim(d.版距)' => '版距'
|
|
|
-// ])
|
|
|
-// ->where('a.sczl_rq','like',$mouth.'%')
|
|
|
-// ->where('a.sczl_jtbh', $value['设备编号'])
|
|
|
-// ->where('a.sczl_bzdh', $v['sczl_bzdh'])
|
|
|
-// ->group('sczl_bzdh,day')
|
|
|
-// ->select();
|
|
|
-// $day_total = [];
|
|
|
-// foreach ($day_cl as $index=>$item){
|
|
|
-// if ($item['印刷方式'] === '卷对卷'){
|
|
|
-// $day_cl[$index]['total_cl'] = round($item['total_cl']/$item['版距']*1000);
|
|
|
-// }
|
|
|
-// $day_total[$item['day']] =$day_cl[$index]['total_cl'];
|
|
|
-// }
|
|
|
-// $data['total'][$key][$k]['day_total'] = $day_total;
|
|
|
-// $data['total'][$key][$k]['total_cl'] = array_sum($day_total);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $this->success('成功',$data);
|
|
|
-// }
|
|
|
public function MachineProduction()
|
|
|
{
|
|
|
// 验证请求方式
|
|
|
@@ -331,63 +254,6 @@ class Decision extends Api
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
-// public function MachineOperation()
|
|
|
-// {
|
|
|
-// if ($this->request->isGet() === false){
|
|
|
-// $this->error('请求错误');
|
|
|
-// }
|
|
|
-// $param = $this->request->param();
|
|
|
-// if (empty($param['mouth'])){
|
|
|
-// $this->error('参数错误');
|
|
|
-// }
|
|
|
-// $where = [];
|
|
|
-// if(!empty($param['sist'])){
|
|
|
-// $where['a.设备编组'] = $param['sist'];
|
|
|
-// }
|
|
|
-// //将参数装换成标准日期格式
|
|
|
-// $mouth = date_create_from_format('Ym', $param['mouth'])->format('Y-m');
|
|
|
-// $list = \db('设备_基本资料')
|
|
|
-// ->alias('a')
|
|
|
-// ->join('设备_产量计酬 b', 'a.设备编号 = b.sczl_jtbh')
|
|
|
-// ->join('工单_印件资料 c', 'b.sczl_gdbh = c.Yj_Gdbh AND b.sczl_yjno = c.yj_Yjno')
|
|
|
-// ->join('工单_工艺资料 d', 'b.sczl_gdbh = d.Gy0_gdbh AND b.sczl_yjno = d.Gy0_yjno AND b.sczl_gxh = d.Gy0_gxh')
|
|
|
-// ->field([
|
|
|
-// 'a.设备编号' => '设备编号',
|
|
|
-// 'rtrim(a.设备名称)' => '设备名称',
|
|
|
-// 'SUM(CASE WHEN rtrim(d.版距) = "卷对卷" THEN b.sczl_cl / NULLIF(d.版距, 0) * 1000 ELSE b.sczl_cl END) AS 产量',
|
|
|
-// 'SUM(b.sczl_设备运行工时)' => '设备运行工时',
|
|
|
-// 'SUM(b.sczl_保养工时)' => '保养工时',
|
|
|
-// 'SUM(b.sczl_打样总工时)' => '打样总工时',
|
|
|
-// 'SUM(b.sczl_打样工时)' => '打样补产工时',
|
|
|
-// 'SUM(b.sczl_装版总工时)' => '装版总工时',
|
|
|
-// 'SUM(b.sczl_装版工时)' => '装板补产工时',
|
|
|
-// 'SUM(b.sczl_异常停机工时)' => '异常停机工时',
|
|
|
-// 'rtrim(d.印刷方式)' => '印刷方式',
|
|
|
-// 'rtrim(d.版距)' => '版距'
|
|
|
-// ])
|
|
|
-// ->where($where)
|
|
|
-// ->where('b.sczl_rq','like', $mouth.'%')
|
|
|
-// ->group('a.设备编号')
|
|
|
-// ->order('a.设备编号')
|
|
|
-// ->select();
|
|
|
-// $total = \db('设备_基本资料')
|
|
|
-// ->alias('a')
|
|
|
-// ->join('设备_产量计酬 b','a.设备编号 = b.sczl_jtbh')
|
|
|
-// ->field([
|
|
|
-// 'SUM(b.sczl_设备运行工时)' => '设备运行工时',
|
|
|
-// 'SUM(b.sczl_保养工时)' => '保养工时',
|
|
|
-// 'SUM(b.sczl_打样总工时)' => '打样总工时',
|
|
|
-// 'SUM(b.sczl_打样工时)' => '打样补产工时',
|
|
|
-// 'SUM(b.sczl_装版总工时)' => '装板总工时',
|
|
|
-// 'SUM(b.sczl_装版工时)' => '装板补产工时',
|
|
|
-// 'SUM(b.sczl_异常停机工时)' => '异常停机工时'
|
|
|
-// ])
|
|
|
-// ->where($where)
|
|
|
-// ->where('b.sczl_rq','like', $mouth.'%')
|
|
|
-// ->find();
|
|
|
-// $list['total'] = $total;
|
|
|
-// $this->success('成功',$list);
|
|
|
-// }
|
|
|
public function MachineOperation()
|
|
|
{
|
|
|
// 确保请求是GET
|
|
|
@@ -584,7 +450,7 @@ class Decision extends Api
|
|
|
->alias('a')
|
|
|
->join('工单_工艺资料 b','a.Gy0_gdbh = b.Gy0_gdbh AND a.印件及工序 = b.Gy0_yjno AND a.工序 = b.Gy0_gxh')
|
|
|
->join('工单_印件资料 c','a.Gy0_gdbh = c.Yj_Gdbh AND a.印件及工序 = c.yj_Yjno')
|
|
|
- ->field('a.sys_ny,(a.计划损耗+sum(a.班组质检废品))/a.印件工序产量 as 废品率')
|
|
|
+ ->field('a.sys_ny,((sum(a.班组制程废品)/a.联数)+(sum(a.班组质检废品)/a.联数))/a.印件工序产量 as 废品率')
|
|
|
->where('b.Gy0_gxmc','like',$item.'%')
|
|
|
->where('a.sys_ny',$value)
|
|
|
->group('a.Gy0_gdbh,b.Gy0_yjno,a.工序')
|