OracleActAllocationDetailService.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Services;
  3. use Illuminate\Support\Facades\DB;
  4. /**
  5. * connection : oracle
  6. * table : ACT_ALLOCATION_DETAILS
  7. */
  8. Class OracleActAllocationDetailService
  9. {
  10. public function paginate(array $params){
  11. $page = $params['page'] ?? 1;
  12. $pagiante = $params['pagiante'] ?? 50;
  13. if (!is_numeric($page) || !is_numeric($pagiante))return;
  14. $sql = "SELECT ACT_ALLOCATION_DETAILS.* FROM(SELECT ACT_ALLOCATION_DETAILS.*,ROWNUM rn FROM
  15. (SELECT orderno FROM ACT_ALLOCATION_DETAILS WHERE 1=1 ";
  16. if ($params['checktime_start'] ?? false){
  17. $sql .= " AND checktime >= '".$params['checktime_start']." 00:00:00'";
  18. }
  19. if ($params['checktime_end'] ?? false){
  20. $sql .= " AND checktime <= '".$params['checktime_end']." 23:59:59'";
  21. }
  22. $sql .= "GROUP BY orderno)ACT_ALLOCATION_DETAILS)ACT_ALLOCATION_DETAILS
  23. WHERE ACT_ALLOCATION_DETAILS.rn <= ".$page*$pagiante." AND rn >".($page-1)*$pagiante;
  24. return DB::connection('oracle')->select(DB::raw($sql));
  25. }
  26. public function getOrderno(array $params){
  27. $allocations = $this->paginate($params);
  28. $count = count($allocations);
  29. $str = "(";
  30. foreach ($allocations as $index => $allocation){
  31. if ($index < $count-1){
  32. $str .= "'".$allocation->orderno."',";
  33. }else{
  34. $str .= "'".$allocation->orderno."')";
  35. }
  36. }
  37. return $str;
  38. }
  39. }