| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- namespace App\Http\Controllers;
- use App\Exports\DefaultExport;
- use App\Services\WaveService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Gate;
- use Maatwebsite\Excel\Facades\Excel;
- class WaveController extends Controller
- {
- public function __construct()
- {
- app()->bind("WaveService",WaveService::class);
- }
- // 主页
- public function index(Request $request){
- if(!Gate::allows('订单管理-波次-查询')){ return redirect(url('/')); }
- $waveService = app("WaveService");
- $waves = $waveService->queryWave($request);
- //$waveStatus = $waveService->getWaveStatus();
- $param = $waveService->getPageParameter($request);
- $search = $waveService->getSearchCondition($request);
- foreach ($waves as $index=>$wave){
- $wave->pickerPrint = '';
- $wave->pickerPrintTime = '';
- $wave->expressPrinting = '';
- $wave->expressPrintTime = '';
- if(!is_null($wave->userdefine1)){
- $str = $wave->userdefine1;
- $index = strpos($str,'-PK');
- $wave->pickerPrint = substr($str,0,$index);
- $wave->pickerPrintTime = substr($str,$index+3);
- }
- if(!is_null($wave->userdefine2)){
- $str = $wave->userdefine2;
- if(strpos($str,'-EX')){
- $index = strpos($str,'-EX');
- $wave->expressPrinting = substr($str,0,$index);
- $wave->expressPrintTime = substr($str,$index+3);
- }else if(strpos($str,'-Auto')){
- $index = strpos($str,'-Auto');
- $wave->expressPrinting = substr($str,0,$index);
- $wave->expressPrintTime = substr($str,$index+5);
- }
- }
- }
- return view("order/wave/search",compact('waves','param','search'));
- }
- public function create(){
- }
- // todo
- public function store(Request $request){
- }
- public function edit($id){
- }
- public function update(Request $request, $id){
- }
- public function destroy($id){
- }
- public function cancelPrinting(Request $request){
- if(!Gate::allows('订单管理-波次-取消打印标记')){ return ['success'=>false,'fail_info'=>'没有权限,请联系管理员']; }
- $waveService = app("WaveService");
- $meg = ['success'=>false];
- $ids = $request->input("ids");
- $meg = $waveService->cancelPrint($ids);
- if($meg['fail_info']){
- return $meg;
- }
- $this->log(__METHOD__,'取消打印标记'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
- return $meg;
- }
- //
- public function exportExcelOnParams(Request $request){
- $waveService = app("WaveService");
- ini_set('max_execution_time',2500);
- ini_set('memory_limit','1526M');
- $waves = $waveService->downloadExec($request);
- $row = $waveService->getExcelFromHead();
- $data = [];
- foreach ($waves as $index=>$wave){
- $arr= [
- 'waveNo' => $wave->waveno,
- 'codename_c' => $wave->codename_c,
- 'waveRule' => $wave->waverule,
- 'descr' => $wave->descr,
- 'descr_c' => $wave->descr_c,
- 'addWho' => $wave->addwho,
- 'addTime' => $wave->addtime,
- 'pickerPrint'=>'',
- 'pickerPrintTime'=>'',
- 'expressPrinting'=>'',
- 'expressPrintTime'=> ''
- ];
- if(!is_null($wave->userdefine1)){
- $str = $wave->userdefine1;
- $index = strpos($str,'-PK');
- $arr['pickerPrint'] = substr($str,0,$index);
- $arr['pickerPrintTime']= substr($str,$index+3);
- }
- if(!is_null($wave->userdefine2)){
- $str = $wave->userdefine2;
- if(strpos($str,'-EX')){
- $index = strpos($str,'-EX');
- $arr['expressPrinting'] =substr($str,0,$index);
- $arr['expressPrintTime'] = substr($str,$index+3);
- }else if(strpos($str,'-Auto')){
- $index = strpos($str,'-Auto');
- $arr['expressPrinting'] =substr($str,0,$index);
- $arr['expressPrintTime'] = substr($str,$index+5);
- }
- }
- $data[] = $arr;
- }
- return Excel::download(new DefaultExport($row,$data),date('YmdHis', time()).'-波次表.xlsx');
- }
- }
|