|  |  | 
 |  |  | package com.doumee.service.business.impl; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | 
 |  |  |         String[] params = new String[3]; | 
 |  |  |         params[0] = user.getRealname(); | 
 |  |  |         params[1]=DateUtil.getPlusTime2(date); | 
 |  |  |         params[2]=job.getBillCode()+"-【司机:"+job.getDriverName()+" "+job.getDrivierPhone()+"】-【车牌号:"+job.getCarCodeFront()+"】"; | 
 |  |  |         params[2]="【运单号:"+job.getBillCode()+"】-【司机:"+job.getDriverName()+" "+job.getDrivierPhone()+"】-【车牌号:"+job.getCarCodeFront()+"】"; | 
 |  |  |         //记录删除日志 | 
 |  |  |         UserActionServiceImpl.saveUserActionBiz(user,id,Constants.UserActionType.PLATFROM_JOB_DEL,userActionMapper,date,params,JSONObject.toJSONString(job)); | 
 |  |  |     } | 
 |  |  | 
 |  |  |                 .isNull(pageWrap.getModel().getJobType() != null && Constants.equalsInteger(Constants.ZERO,pageWrap.getModel().getJobType()), PlatformJob::getContractNum) | 
 |  |  |                 .exists(StringUtils.isNotBlank(pageWrap.getModel().getWmsContractNum()), | 
 |  |  |                         "select tt.id from platform_wms_detail tt where tt.isdeleted=0 and tt.contract_num='"+pageWrap.getModel().getWmsContractNum()+"' and  tt.job_id=t.id"); | 
 |  |  |  | 
 |  |  |         for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
 |  |  |         queryWrapper.orderByDesc(PlatformJob::getCreateDate); | 
 |  |  |         /*for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
 |  |  |             if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
 |  |  |                 queryWrapper.orderByDesc(sortData.getProperty()); | 
 |  |  |             } else { | 
 |  |  |                 queryWrapper.orderByAsc(sortData.getProperty()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         }*/ | 
 |  |  |        IPage<PlatformJob> platformJobIPage = platformJobJoinMapper.selectJoinPage(page,PlatformJob.class,queryWrapper); | 
 |  |  |         platformJobIPage.getRecords().forEach(i->{ | 
 |  |  |             i.dealTime(); | 
 |  |  | 
 |  |  |                 .selectAs(Platform::getName,PlatformJob::getPlatformName) | 
 |  |  |                 .selectAs(Platform::getWorkRate,PlatformJob::getWorkRate) | 
 |  |  |                 .selectAs(PlatformWmsJob::getCarrierName,PlatformJob::getCarrierName) | 
 |  |  |                 .select(" case when t.total_num is null  then ( select sum(pwd.IO_QTY) from platform_wms_detail pwd where pwd.JOB_ID = t.id  ) else t.total_num end ioQty ") | 
 |  |  |                 .select(" (select GROUP_CONCAT(distinct(tt.contract_num ))  from platform_wms_detail tt where tt.isdeleted=0 and tt.contract_num is not null   and  tt.job_id=t.id )as wmsContractNum") | 
 |  |  | //                .select(" case when t.total_num is null  then ( select sum(pwd.IO_QTY) from platform_wms_detail pwd where pwd.JOB_ID = t.id  ) else t.total_num end ioQty ") | 
 |  |  |                 .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) | 
 |  |  |                 .leftJoin(PlatformWmsJob.class,PlatformWmsJob::getCarryBillCode,PlatformJob::getBillCode) | 
 |  |  |                 .leftJoin(PlatformBooks.class,PlatformBooks::getJobId,PlatformJob::getId) | 
 |  |  | 
 |  |  |                 ) | 
 |  |  | //                .like(PlatformJob::getArriveDate,DateUtil.dateTypeToString(new Date(),"yyyy-MM-dd")) | 
 |  |  |                 .orderByDesc(PlatformJob::getStatus) | 
 |  |  |                 .orderByAsc(PlatformJob::getSignDate) | 
 |  |  |         ; | 
 |  |  |         IPage<PlatformJob> platformJobIPage = platformJobJoinMapper.selectJoinPage(page,PlatformJob.class,queryWrapper); | 
 |  |  |         platformJobIPage.getRecords().forEach(i->{ | 
 |  |  |             i.dealTime(); | 
 |  |  |             i.setTotalNum(i.getIoQty()); | 
 |  |  |             if(Constants.equalsInteger(i.getOrigin(),Constants.ZERO)){ | 
 |  |  |                 i.setWmsContractNum(i.getContractNum()); | 
 |  |  |             } | 
 |  |  | //            i.setTotalNum(i.getIoQty()); | 
 |  |  | //            this.getWmsJobData(i); | 
 |  |  | //            this.queryWaitNum(i); | 
 |  |  |         }); | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(confirmTaskDTO.getId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(!Constants.equalsInteger(platformJob.getStatus(),Constants.ZERO)){ | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(signInDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | 
 |  |  |         } | 
 |  |  |         //查询今日最大的签到数 | 
 |  |  |         List<PlatformJob> signList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>().lambda() | 
 |  |  |                 .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .apply(" DATE(SIGN_DATE) = DATE(NOW()) and sign_date is not null  ")); | 
 |  |  |         if(CollectionUtils.isEmpty(signList)){ | 
 |  |  |             platformJob.setSignNum(Constants.ONE); | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob  = platformJobMapper.selectById(jobDetailDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){ | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WAIT_CALL.getKey())){ | 
 |  |  | 
 |  |  |                             .eq(PlatformJob::getId,platformJob.getId()) | 
 |  |  |                             .last(" limit 1") | 
 |  |  |             ); | 
 |  |  |  | 
 |  |  |             WxPlatNotice wxPlatNotice = new WxPlatNotice(); | 
 |  |  |             wxPlatNotice.sendPlatformJobTemplateNotice(systemDictDataBiz, | 
 |  |  |                     wxNoticeConfigMapper, p, | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(!(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WAIT_CALL.getKey()) | 
 |  |  | 
 |  |  |         //查询月台任务等待作业数量 | 
 |  |  |         if(platformJobMapper.selectCount(new QueryWrapper<PlatformJob>().lambda() | 
 |  |  |                 .eq(PlatformJob::getPlatformId,platform.getId()) | 
 |  |  |                 .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .in(PlatformJob::getStatus,Constants.PlatformJobStatus.CALLED.getKey(),Constants.PlatformJobStatus.WORKING.getKey()) | 
 |  |  |         )>=platform.getWorkingNum()){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"超出月台可同时作业数量["+platform.getWorkingNum()+"辆]"); | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if( !( Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey()) | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){ | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.CALLED.getKey())){ | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(! (Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey()) | 
 |  |  | 
 |  |  |            if(jobIds.size()>0){ | 
 |  |  |                List<PlatformJob> list = platformJobMapper.selectJoinList(PlatformJob.class,new MPJLambdaWrapper<PlatformJob>() | 
 |  |  |                        .selectAll(PlatformJob.class) | 
 |  |  |                        .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
 |  |  |                        .eq(PlatformJob::getStatus,Constants.PlatformJobStatus.DONE.getKey()) | 
 |  |  |                        .in(PlatformJob::getId,jobIds) | 
 |  |  |                ); | 
 |  |  | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         PlatformJob platformJob = platformJobMapper.selectById(jobOperateDTO.getJobId()); | 
 |  |  |         if(Objects.isNull(platformJob)){ | 
 |  |  |         if(Objects.isNull(platformJob)||Constants.equalsInteger(platformJob.getIsdeleted(),Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
 |  |  |         } | 
 |  |  |         if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.DONE.getKey())){ | 
 |  |  | 
 |  |  |         PlatformJob platformJob =  platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda() | 
 |  |  |                 .eq(PlatformJob::getPlatformId,platformDevice.getPlatformId()) | 
 |  |  |                 .eq(PlatformJob::getCarCodeBack,jobOperateDTO.getCarCodeBack()) | 
 |  |  |                 .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(PlatformJob::getStatus,Constants.PlatformJobStatus.CALLED.getKey()) | 
 |  |  |                 .last(" limit 1 ") | 
 |  |  |         ); | 
 |  |  | 
 |  |  |                 .select(" ( select pl.CREATE_DATE from platform_log pl where t.id = pl.obj_id and pl.OBJ_TYPE = "+Constants.PlatformJobLogType.WORKING.getKey()+" order by pl.CREATE_DATE desc  limit 1  ) as newStartDate  ") | 
 |  |  |                 .select(" ( select pl.CREATE_DATE from platform_log pl where t.id = pl.obj_id and pl.OBJ_TYPE = "+Constants.PlatformJobLogType.CALLED.getKey()+" order by pl.CREATE_DATE desc  limit 1  ) as newCallDate  ") | 
 |  |  |                 .select(" case when t.total_num is null  then ( select sum(pwd.IO_QTY) from platform_wms_detail pwd where pwd.JOB_ID = t.id  ) else t.total_num end ioQty ") | 
 |  |  |                 .select(" (select GROUP_CONCAT(distinct(tt.contract_num )) from platform_wms_detail tt where tt.isdeleted=0 and tt.contract_num is not null  and  tt.job_id=t.id )as wmsContractNum") | 
 |  |  |                 .selectAs(Platform::getName,PlatformJob::getPlatformName) | 
 |  |  |                 .selectAs(Platform::getWorkRate,PlatformJob::getWorkRate) | 
 |  |  |                 .selectAs(PlatformWmsJob::getCarrierName,PlatformJob::getCarrierName) | 
 |  |  | 
 |  |  |         ); | 
 |  |  |         //查询今日完成任务 | 
 |  |  |         platformOrderNumByDateResponse.setDoneNum( | 
 |  |  |                 platformJobMapper.selectCount(new QueryWrapper<PlatformJob>().lambda() | 
 |  |  |                 platformJobMapper.selectCount(new MPJLambdaWrapper<PlatformJob>() | 
 |  |  |                         .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .like(PlatformJob::getDoneDate,queryDateStr) | 
 |  |  |                         .eq(PlatformJob::getStatus,Constants.PlatformJobStatus.DONE.getKey()) | 
 |  |  |                         .in(PlatformJob::getStatus,Constants.PlatformJobStatus.DONE.getKey() | 
 |  |  |                                 ,Constants.PlatformJobStatus.AUTHED_LEAVE.getKey() | 
 |  |  |                                 ,Constants.PlatformJobStatus.LEAVED.getKey()) | 
 |  |  |                 ) | 
 |  |  |         ); | 
 |  |  |         return platformOrderNumByDateResponse; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<PlatformDataListResponse> platformWorkingDataList(PlatformDataListRequest param){ |