|
|
@@ -134,17 +134,6 @@ class MachineProductionReport extends Api
|
|
|
ORDER BY sys_id';
|
|
|
$arr = db()->query($sql);
|
|
|
|
|
|
- // $arr1 = db('设备_产量计酬')->cache(true,3600)
|
|
|
- // ->field('sczl_gdbh,rtrim(sys_id) as sys_id')
|
|
|
- // ->where('sczl_gdbh','>=',$rows[count($rows)-1]['sczl_gdbh'])
|
|
|
- // ->select();
|
|
|
-
|
|
|
- // $arr2 = db('db_sczl')->cache(true,3600)
|
|
|
- // ->field('sczl_gdbh,rtrim(sys_id) as sys_id')
|
|
|
- // ->where('sczl_gdbh','>=',$rows[count($rows)-1]['sczl_gdbh'])
|
|
|
- // ->select();
|
|
|
- // $arr = array_merge($arr1,$arr2);
|
|
|
-
|
|
|
$brr = [];
|
|
|
foreach($arr as $k=>$v){
|
|
|
if(array_key_exists($v['sczl_gdbh'],$brr)){
|
|
|
@@ -198,8 +187,41 @@ class MachineProductionReport extends Api
|
|
|
$sql .= ') as t';
|
|
|
$total = db()->query($sql)[0]['count'];
|
|
|
|
|
|
- //判断是否存在缓存
|
|
|
- if (!cache('ReportGetList-'.$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit'])){
|
|
|
+ if (cache('MachineProductReport-getList')){
|
|
|
+ if(array_key_exists($req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit'] , cache('MachineProductReport-getList'))){
|
|
|
+ $rows = cache('MachineProductReport-getList')[$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']];
|
|
|
+ }else{
|
|
|
+ //UNION 查询两表数据
|
|
|
+ // db_sczl缺少数据 --> a.sczl_来料少数,
|
|
|
+ // 设备_产量计酬缺少数据 --> a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
+ $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
+ a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
|
|
|
+ a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
+ a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数,
|
|
|
+ d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数,
|
|
|
+ rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
|
|
|
+ FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
|
|
|
+ $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
|
|
|
+ $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` = "'.$req['sys_id'].'" ' : '';
|
|
|
+ $sql .= 'UNION ALL
|
|
|
+ SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
+ a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
|
|
|
+ a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
+ a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数,
|
|
|
+ d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
+ rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
|
|
|
+ FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
|
|
|
+ $sql .= strpos($req['date'],'-') ? 'WHERE `a`.`sys_rq` LIKE "'.$req['date'].'%" ' : 'WHERE `a`.`sczl_gdbh` = "'.$req['date'].'" ';
|
|
|
+ $sql .= isset($req['sys_id']) && !empty($req['sys_id']) ? 'AND `a`.`sys_id` = "'.$req['sys_id'].'" ' : '';
|
|
|
+ $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
|
|
|
+ $rows = db()->query($sql);
|
|
|
+
|
|
|
+ //设置缓存
|
|
|
+ $cache = cache('MachineProductReport-getList');
|
|
|
+ $cache[$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']] = $rows;
|
|
|
+ cache('MachineProductReport-getList',$cache,3600);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
//UNION 查询两表数据
|
|
|
// db_sczl缺少数据 --> a.sczl_来料少数,
|
|
|
// 设备_产量计酬缺少数据 --> a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
@@ -226,9 +248,9 @@ class MachineProductionReport extends Api
|
|
|
$rows = db()->query($sql);
|
|
|
|
|
|
//设置缓存
|
|
|
- cache('ReportGetList-'.$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit'],$rows,3600);
|
|
|
- }else{
|
|
|
- $rows = cache('ReportGetList-'.$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']);
|
|
|
+ $cache = [];
|
|
|
+ $cache[$req['date'].'-'.$req['sys_id'].'-'.$req['page'].'-'.$req['limit']] = $rows;
|
|
|
+ cache('MachineProductReport-getList',$cache,3600);
|
|
|
}
|
|
|
|
|
|
$gd = db('工单_基本资料')->cache(true,86400)->column('Gd_gdbh, 成品名称 as Gd_cpmc');
|
|
|
@@ -309,7 +331,37 @@ class MachineProductionReport extends Api
|
|
|
$total = db()->query($sql)[0]['count'];
|
|
|
|
|
|
//判断缓存是否存在
|
|
|
- if (!cache('ReportGetList-'.$req['gdbh'].'-'.$req['page'].'-'.$req['limit'])){
|
|
|
+ if (cache('MachineProductReport-getList')){
|
|
|
+ if(array_key_exists($req['gdbh'].'-'.$req['page'].'-'.$req['limit'] , cache('MachineProductReport-getList'))){
|
|
|
+ $rows = cache('MachineProductReport-getList')[$req['gdbh'].'-'.$req['page'].'-'.$req['limit']];
|
|
|
+ }else{
|
|
|
+ //a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
+ $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
+ a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
|
|
|
+ a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
+ a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数,
|
|
|
+ d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数,
|
|
|
+ rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
|
|
|
+ FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
|
|
|
+ $sql .= 'WHERE `a`.`sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
|
|
|
+ $sql .= 'UNION ALL
|
|
|
+ SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
+ a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
|
|
|
+ a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
+ a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数,
|
|
|
+ d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
+ rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
|
|
|
+ FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh`';
|
|
|
+ $sql .= 'WHERE `a`.`sczl_gdbh` LIKE "%'.$req['gdbh'].'%" ';
|
|
|
+ $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
|
|
|
+ $rows = db()->query($sql);
|
|
|
+
|
|
|
+ //设置缓存
|
|
|
+ $cache = cache('MachineProductReport-getList');
|
|
|
+ $cache[$req['gdbh'].'-'.$req['page'].'-'.$req['limit']] = $rows;
|
|
|
+ cache('MachineProductReport-getList',$cache,3600);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
//a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
$sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
|
|
|
@@ -331,10 +383,12 @@ class MachineProductionReport extends Api
|
|
|
$sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
|
|
|
$rows = db()->query($sql);
|
|
|
|
|
|
- cache('ReportGetList-'.$req['gdbh'].'-'.$req['page'].'-'.$req['limit'],$rows,3600);
|
|
|
- }else{
|
|
|
- $rows = cache('ReportGetList-'.$req['gdbh'].'-'.$req['page'].'-'.$req['limit']);
|
|
|
- }
|
|
|
+ //设置缓存
|
|
|
+ $cache = [];
|
|
|
+ $cache[$req['gdbh'].'-'.$req['page'].'-'.$req['limit']] = $rows;
|
|
|
+ cache('MachineProductReport-getList',$cache,3600);
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
if (isset($req['cpmc']) && !empty($req['cpmc'])){
|
|
|
//查询包括该名称的工单号
|
|
|
@@ -352,7 +406,37 @@ class MachineProductionReport extends Api
|
|
|
$sql .= ') as t';
|
|
|
$total = db()->query($sql)[0]['count'];
|
|
|
|
|
|
- if (!cache('ReportGetList-'.$req['gdbh'].'-'.$req['cpmc'].'-'.$req['limit'])){
|
|
|
+ //判断缓存是否存在
|
|
|
+ if (cache('MachineProductReport-getList')){
|
|
|
+ if(array_key_exists($req['cpmc'].'-'.$req['page'].'-'.$req['limit'] , cache('MachineProductReport-getList'))){
|
|
|
+ $rows = cache('MachineProductReport-getList')[$req['cpmc'].'-'.$req['page'].'-'.$req['limit']];
|
|
|
+ }else{
|
|
|
+ $sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
+ a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
|
|
|
+ a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
+ a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数,
|
|
|
+ d.日定额, d.千件工价, d.补产标准, a.sczl_来料少数, NULL AS 拆片联拼系数, NULL AS 拆片条小盒系数,
|
|
|
+ rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "设备_产量计酬" AS table_type
|
|
|
+ FROM `设备_产量计酬` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
|
|
|
+ $sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
|
|
|
+ $sql .= 'UNION ALL
|
|
|
+ SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
+ a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_fp as sczl_zcfp, a.sczl_cp as sczl_zccp,
|
|
|
+ a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
+ a.sczl_bh1, a.sczl_bh2, a.sczl_bh3, a.sczl_bh4, a.sczl_bh5, a.sczl_bh6, a.sczl_工价系数,
|
|
|
+ d.日定额, d.千件工价, d.补产标准, NULL AS sczl_来料少数, a.拆片联拼系数, a.拆片条小盒系数,
|
|
|
+ rtrim(a.sys_id) as sys_id, a.sys_rq, a.mod_rq, a.UniqId, "db_sczl" AS table_type
|
|
|
+ FROM `db_sczl` `a` LEFT JOIN `dic_lzde` `d` ON `a`.`sczl_dedh`=`d`.`sys_bh` ';
|
|
|
+ $sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
|
|
|
+ $sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
|
|
|
+ $rows = db()->query($sql);
|
|
|
+
|
|
|
+ //设置缓存
|
|
|
+ $cache = cache('MachineProductReport-getList');
|
|
|
+ $cache[$req['cpmc'].'-'.$req['page'].'-'.$req['limit']] = $rows;
|
|
|
+ cache('MachineProductReport-getList',$cache,3600);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
$sql = 'SELECT a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_type, LEFT(a.sczl_rq, 10) as sczl_rq, a.sczl_jtbh,
|
|
|
a.sczl_bzdh, a.sczl_num, a.sczl_cl, a.sczl_ms, a.sczl_zcfp, a.sczl_zccp,
|
|
|
a.sczl_装版工时, a.sczl_保养工时, a.sczl_打样工时, a.sczl_异常停机工时, a.sczl_设备运行工时,
|
|
|
@@ -372,9 +456,11 @@ class MachineProductionReport extends Api
|
|
|
$sql .= 'WHERE `a`.`sczl_gdbh` IN ('.$in.') ';
|
|
|
$sql .= 'ORDER BY sys_id ASC, sczl_num ASC LIMIT '.($page-1)*$limit.','.$limit;
|
|
|
$rows = db()->query($sql);
|
|
|
- cache('ReportGetList-'.$req['cpmc'].'-'.$req['page'].'-'.$req['limit'],$rows,3600);
|
|
|
- }else{
|
|
|
- $rows = cache('ReportGetList-'.$req['cpmc'].'-'.$req['page'].'-'.$req['limit']);
|
|
|
+
|
|
|
+ //设置缓存
|
|
|
+ $cache = [];
|
|
|
+ $cache[$req['cpmc'].'-'.$req['page'].'-'.$req['limit']] = $rows;
|
|
|
+ cache('MachineProductReport-getList',$cache,3600);
|
|
|
}
|
|
|
}else{
|
|
|
$this->error('参数错误');
|
|
|
@@ -755,6 +841,7 @@ class MachineProductionReport extends Api
|
|
|
$bool = db()->query($sql);
|
|
|
// 提交事务
|
|
|
db()->commit();
|
|
|
+ cache('MachineProductReport-getList',null);
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
db()->rollback();
|
|
|
@@ -806,6 +893,7 @@ class MachineProductionReport extends Api
|
|
|
$bool = db()->query($sql);
|
|
|
// 提交事务
|
|
|
db()->commit();
|
|
|
+ cache('MachineProductReport-getList',null);
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
db()->rollback();
|
|
|
@@ -837,9 +925,9 @@ class MachineProductionReport extends Api
|
|
|
db()->startTrans();
|
|
|
try{
|
|
|
$bool = db('db_sczl')->where('UniqId',$req['UniqId'])->delete();
|
|
|
-
|
|
|
// 提交事务
|
|
|
db()->commit();
|
|
|
+ cache('MachineProductReport-getList',null);
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
db()->rollback();
|