|
@@ -649,4 +649,85 @@ class Decision extends Api
|
|
|
? $this->success('成功', $data)
|
|
? $this->success('成功', $data)
|
|
|
: $this->error('未找到数据');
|
|
: $this->error('未找到数据');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //月度色度数导出
|
|
|
|
|
+ public function ChromaticityNumber()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param['month'])) {
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [];
|
|
|
|
|
+ // 将参数转换成标准日期格式
|
|
|
|
|
+ $mouth = date_create_from_format('Ym', $param['month'])->format('Y-m');
|
|
|
|
|
+ $where['a.sczl_rq'] = ['like', $mouth . '%'];
|
|
|
|
|
+
|
|
|
|
|
+ // 分页配置
|
|
|
|
|
+ $page = !empty($param['page']) ? (int)$param['page'] : 1;
|
|
|
|
|
+ $limit = !empty($param['limit']) ? (int)$param['limit'] : 9999; // 默认查询所有
|
|
|
|
|
+
|
|
|
|
|
+ // 查询数据
|
|
|
|
|
+ $list = \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' => '工序号',
|
|
|
|
|
+ 'd.Gy0_gxmc' => '工序名称',
|
|
|
|
|
+ 'SUM(a.sczl_cl)' => '产量',
|
|
|
|
|
+ 'a.sczl_ms' => '墨色数',
|
|
|
|
|
+ 'rtrim(d.印刷方式)' => '印刷方式',
|
|
|
|
|
+ 'rtrim(d.版距)' => '版距',
|
|
|
|
|
+ 'rtrim(d.Gy0_SITE)' => '车间名称',
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->group('a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh')
|
|
|
|
|
+ ->page($page, $limit) // 使用 page 和 limit 实现分页
|
|
|
|
|
+ ->select();
|
|
|
|
|
+
|
|
|
|
|
+ // 数据处理
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ if (!empty($list)) {
|
|
|
|
|
+ foreach ($list as $key => $value) {
|
|
|
|
|
+ $parts = explode('-', $value['工序名称']);
|
|
|
|
|
+ $data[$key]['工序名称'] = end($parts);
|
|
|
|
|
+ // 产量计算
|
|
|
|
|
+ if ($value['印刷方式'] === '卷对卷') {
|
|
|
|
|
+ $list[$key]['产量'] = round($value['产量'] / $value['版距'] * 1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ $data[$key]['墨色'] = $list[$key]['产量'] * $value['墨色数'];
|
|
|
|
|
+ $data[$key]['车间'] = $value['车间名称'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $result = [];
|
|
|
|
|
+ foreach ($data as $item) {
|
|
|
|
|
+ $workshop = $item['车间'];
|
|
|
|
|
+ $process = $item['工序名称'];
|
|
|
|
|
+ $ink = $item['墨色'];
|
|
|
|
|
+
|
|
|
|
|
+ // 生成唯一分组键
|
|
|
|
|
+ $key = $workshop . '|' . $process;
|
|
|
|
|
+
|
|
|
|
|
+ if (isset($result[$key])) {
|
|
|
|
|
+ // 累加墨色值
|
|
|
|
|
+ $result[$key]['墨色'] += $ink;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 创建新分组
|
|
|
|
|
+ $result[$key] = [
|
|
|
|
|
+ '工序名称' => $process,
|
|
|
|
|
+ '墨色' => $ink,
|
|
|
|
|
+ '车间' => $workshop
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $result = array_values($result);
|
|
|
|
|
+
|
|
|
|
|
+ $this->success('成功', $result);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|