|
|
@@ -321,26 +321,91 @@ 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()
|
|
|
{
|
|
|
- if ($this->request->isGet() === false){
|
|
|
+ // 确保请求是GET
|
|
|
+ if ($this->request->isGet() === false) {
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
$param = $this->request->param();
|
|
|
- if (empty($param['mouth'])){
|
|
|
+ if (empty($param['mouth'])) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
+
|
|
|
+ // 构建查询条件
|
|
|
$where = [];
|
|
|
- if(!empty($param['sist'])){
|
|
|
+ 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')
|
|
|
+ ->join('工单_工艺资料 d', 'b.sczl_gdbh = d.Gy0_gdbh AND b.sczl_yjno = d.Yj_Yjno AND b.sczl_gxh = d.Gy0_gxh')
|
|
|
->field([
|
|
|
'a.设备编号' => '设备编号',
|
|
|
'rtrim(a.设备名称)' => '设备名称',
|
|
|
@@ -356,29 +421,39 @@ class Decision extends Api
|
|
|
'rtrim(d.版距)' => '版距'
|
|
|
])
|
|
|
->where($where)
|
|
|
- ->where('b.sczl_rq','like', $mouth.'%')
|
|
|
+ ->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();
|
|
|
+
|
|
|
+ // 处理总工时的计算
|
|
|
+ $total = [
|
|
|
+ '设备运行工时' => 0,
|
|
|
+ '保养工时' => 0,
|
|
|
+ '打样总工时' => 0,
|
|
|
+ '打样补产工时' => 0,
|
|
|
+ '装版总工时' => 0,
|
|
|
+ '装版补产工时' => 0,
|
|
|
+ '异常停机工时' => 0
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 计算各项总工时
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $total['设备运行工时'] += $item['设备运行工时'];
|
|
|
+ $total['保养工时'] += $item['保养工时'];
|
|
|
+ $total['打样总工时'] += $item['打样总工时'];
|
|
|
+ $total['打样补产工时'] += $item['打样补产工时'];
|
|
|
+ $total['装版总工时'] += $item['装版总工时'];
|
|
|
+ $total['装版补产工时'] += $item['装版补产工时'];
|
|
|
+ $total['异常停机工时'] += $item['异常停机工时'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将总工时添加到列表中
|
|
|
$list['total'] = $total;
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
|
|
|
+ // 返回成功响应
|
|
|
+ $this->success('成功', $list);
|
|
|
+ }
|
|
|
/**
|
|
|
* 设备运行工时机台生产工单数据详情
|
|
|
* @return void
|