|
|
@@ -146,18 +146,32 @@ class Product extends Api
|
|
|
rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,rtrim(yj_desc) as yj_desc,rtrim(sys_id) as sys_id,sys_rq,mod_rq,UniqId';
|
|
|
$yjRes = db('产品_印件资料')->where($where)->where($PriWhere)->field($field)->select();
|
|
|
//印版资料
|
|
|
- $filter['a.YB_Cpdh'] = $code;
|
|
|
- $yb_field = 'rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,rtrim(a.存货编码) as 存货编码,a.考核印数,rtrim(a.Sys_id) as Sys_id,a.Mod_rq,rtrim(b.物料名称) as 印版名称,rtrim(c.名称) as 印版类别,a.UniqID';
|
|
|
- $ybRes = db('产品_印版资料')->alias('a')
|
|
|
+ $yb_field = 'rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,rtrim(a.存货编码) as 存货编码,a.考核印数,rtrim(a.Sys_id) as Sys_id,a.Mod_rq,
|
|
|
+ rtrim(b.物料名称) as 印版名称,rtrim(c.名称) as 印版类别,a.UniqID,rtrim(d.供方批号) as 供方批号,e.Yb_领用机台 as 领用机台,sum(e.Yb_印数) as 印数,d.UniqID';
|
|
|
+ $query = db('产品_印版资料')->alias('a')
|
|
|
->join('物料_存货编码 b', 'a.存货编码 = b.物料代码', 'left')
|
|
|
->join('物料_存货结构 c',
|
|
|
'LEFT(a.存货编码, CASE WHEN a.存货编码 REGEXP \'[a-zA-Z]\' THEN 5 ELSE 4 END) = c.编号',
|
|
|
'left'
|
|
|
)
|
|
|
- ->where($filter)
|
|
|
- ->field($yb_field)
|
|
|
+ ->join('产品_印版库 d', 'a.存货编码 = d.存货编码', 'left')
|
|
|
+ ->join('工单_印版领用记录 e', 'a.存货编码 = e.Yb_存货编码 and d.供方批号 = e.Yb_供方批号', 'left')
|
|
|
+ ->where('e.Yb_退还日期', null)
|
|
|
->order('a.YB_Yjno,a.存货编码')
|
|
|
- ->select();
|
|
|
+ ->group('a.YB_Yjno,a.存货编码,d.UniqID');
|
|
|
+ // 动态处理$code参数类型
|
|
|
+ if (is_array($code)) {
|
|
|
+ $query->whereIn('a.YB_Cpdh', $code);
|
|
|
+ } else {
|
|
|
+ $query->where('a.YB_Cpdh', $code);
|
|
|
+ }
|
|
|
+ // 添加其他过滤条件
|
|
|
+ if (!empty($filter) && is_array($filter)) {
|
|
|
+ foreach ($filter as $field => $value) {
|
|
|
+ $query->where($field, $value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $ybRes = $query->field($yb_field)->select();
|
|
|
//技术附件
|
|
|
$jsRes = db('产品_技术附件')
|
|
|
->where('关联产品','like','%'.$code.'%')
|