| | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.PlatformJobJoinMapper; |
| | | import com.doumee.dao.business.join.PlatformJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.web.reqeust.JobDetailDTO; |
| | | import com.doumee.dao.web.reqeust.JobOperateDTO; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | |
| | | @Autowired |
| | | private PlatformMapper platformMapper; |
| | | private PlatformJoinMapper platformJoinMapper; |
| | | |
| | | @Autowired |
| | | private PlatformLogMapper platformLogMapper; |
| | |
| | | |
| | | @Autowired |
| | | private PlatformWmsDetailMapper platformWmsDetailMapper; |
| | | |
| | | @Autowired |
| | | private PlatformGroupMapper platformGroupMapper; |
| | | |
| | | @Autowired |
| | | private PlatformShowParamMapper platformShowParamMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public PageData<PlatformJob> findPage(PageWrap<PlatformJob> pageWrap) { |
| | | IPage<PlatformJob> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<PlatformJob> queryWrapper = new QueryWrapper<>(); |
| | | MPJLambdaWrapper<PlatformJob> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | queryWrapper.lambda() |
| | | queryWrapper |
| | | .selectAll(PlatformJob.class) |
| | | .selectAs(Platform::getName,PlatformJob::getPlatformName) |
| | | .selectAs(Platform::getWorkRate,PlatformJob::getWorkRate) |
| | | .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) |
| | | .eq(pageWrap.getModel().getId() != null, PlatformJob::getId, pageWrap.getModel().getId()) |
| | | .eq(pageWrap.getModel().getCreator() != null, PlatformJob::getCreator, pageWrap.getModel().getCreator()) |
| | | .ge(pageWrap.getModel().getCreateDate() != null, PlatformJob::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())) |
| | |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | |
| | | PageData<PlatformJob> pageData = PageData.from(platformJobMapper.selectPage(page, queryWrapper)); |
| | | pageData.getRecords().forEach(i->{ |
| | | IPage<PlatformJob> platformJobIPage = platformJobJoinMapper.selectJoinPage(page,PlatformJob.class,queryWrapper); |
| | | platformJobIPage.getRecords().forEach(i->{ |
| | | i.dealTime(); |
| | | this.getWmsJobData(i); |
| | | }); |
| | | return pageData; |
| | | return PageData.from(platformJobIPage); |
| | | // PageData<PlatformJob> pageData = PageData.from(platformJobMapper.selectPage(page, queryWrapper)); |
| | | // pageData.getRecords().forEach(i->{ |
| | | // i.dealTime(); |
| | | // this.getWmsJobData(i); |
| | | // }); |
| | | // return pageData; |
| | | } |
| | | |
| | | |
| | |
| | | platformWmsJob.setPlatformWmsDetailList(platformWmsDetailList); |
| | | platformJob.setPlatformWmsJob(platformWmsJob); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void queryWaitNum(PlatformJob platformJob){ |
| | | if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WAIT_CALL.getKey())){ |
| | | //查询前方排队数量 |
| | | List<PlatformJob> lineUpNum = platformJobMapper.selectList(new QueryWrapper<PlatformJob>().lambda() |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO) |
| | | .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WAIT_CALL.getKey() |
| | | ,Constants.PlatformJobStatus.IN_WAIT.getKey() |
| | | ,Constants.PlatformJobStatus.TRANSFERING.getKey()) |
| | | .gt(PlatformJob::getSignDate,platformJob.getSignDate()) |
| | | .eq(PlatformJob::getPlatformGroupId,platformJob.getPlatformGroupId()) |
| | | .like(PlatformJob::getArriveDate,DateUtil.getDate(platformJob.getArriveDate(),"yyyy-MM-dd"))); |
| | | platformJob.setLineUpNum(lineUpNum.size()); |
| | | BigDecimal sumWorkRate = platformJob.getTotalNum(); |
| | | for (PlatformJob linePlatformJob:lineUpNum) { |
| | | this.getWmsJobData(linePlatformJob); |
| | | sumWorkRate = sumWorkRate.add(linePlatformJob.getTotalNum()); |
| | | } |
| | | //计算预计等待时间 |
| | | List<Platform> platformList = platformJoinMapper.selectList(new QueryWrapper<Platform>().lambda().eq(Platform::getIsdeleted,Constants.ZERO).eq(Platform::getGroupId,platformJob.getPlatformGroupId())); |
| | | BigDecimal workRate = platformList.stream().map(m->m.getWorkRate()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if(sumWorkRate.compareTo(BigDecimal.ZERO) == Constants.ZERO|| workRate.compareTo(BigDecimal.ZERO) == Constants.ZERO ){ |
| | | BigDecimal sumMinute = sumWorkRate.divide(workRate,1, RoundingMode.HALF_DOWN).multiply(BigDecimal.valueOf(60L)); |
| | | Integer sumMinuteInteger = sumMinute.intValue(); |
| | | Integer hours = sumMinuteInteger/60; |
| | | Integer minus = sumMinuteInteger%60; |
| | | String waitTime = "预计等待:"; |
| | | if(!Constants.equalsInteger(hours,Constants.ZERO)){ |
| | | waitTime = waitTime + hours + "小时"; |
| | | } |
| | | if(!Constants.equalsInteger(hours,Constants.ZERO)){ |
| | | waitTime = waitTime + minus + "分钟"; |
| | | } |
| | | platformJob.setWaitTime(waitTime); |
| | | } |
| | | }else if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){ |
| | | //查询最后开始任务的月台记录 日志表 因为存在异常挂起 转移 等问题 |
| | | PlatformLog platformLog = platformLogMapper.selectOne(new QueryWrapper<PlatformLog>().lambda() |
| | | .eq(PlatformLog::getJobId,platformJob.getId()) |
| | | .eq(PlatformLog::getObjType,Constants.PlatformJobStatus.WORKING.getKey()) |
| | | .orderByDesc(PlatformLog::getCreateDate) |
| | | .last(" limit 1") |
| | | ); |
| | | if(Objects.nonNull(platformLog)){ |
| | | BigDecimal sumMinute = platformJob.getTotalNum().divide(platformJob.getWorkRate(),1, RoundingMode.HALF_DOWN).multiply(BigDecimal.valueOf(60L)); |
| | | platformJob.setFinishTimeStr(DateUtil.DateToStr(DateUtil.afterMinutesDate(platformLog.getCreateDate(),sumMinute.intValue()),"HH:mm")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long count(PlatformJob platformJob) { |
| | | QueryWrapper<PlatformJob> wrapper = new QueryWrapper<>(platformJob); |
| | |
| | | |
| | | //TODO |
| | | @Override |
| | | public DriverHomeVO getDriverHome(Integer memberId){ |
| | | public DriverHomeVO getDriverHome(LoginUserInfo loginUserInfo){ |
| | | DriverHomeVO driverHomeVO = new DriverHomeVO(); |
| | | //TODO 轮播图 |
| | | |
| | | List<PlatformJob> platformJobList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>() |
| | | .lambda() |
| | | .eq(PlatformJob::getDriverId,memberId) |
| | | // .like(PlatformJob::get) |
| | | .orderByDesc(PlatformJob::getId)); |
| | | List<PlatformJob> platformJobList = platformJobJoinMapper.selectJoinList(PlatformJob.class,new MPJLambdaWrapper<PlatformJob>() |
| | | .selectAll(PlatformJob.class) |
| | | .selectAs(Platform::getName,PlatformJob::getPlatformName) |
| | | .selectAs(Platform::getWorkRate,PlatformJob::getWorkRate) |
| | | .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformJob::getDrivierPhone,loginUserInfo.getMobile()) |
| | | .like(PlatformJob::getArriveDate,DateUtil.getCurrDate()) |
| | | .orderByDesc(PlatformJob::getId) |
| | | ); |
| | | for (PlatformJob platformJob:platformJobList) { |
| | | //处理WSM数量 |
| | | this.getWmsJobData(platformJob); |
| | | //查询前方排队数量 |
| | | this.queryWaitNum(platformJob); |
| | | } |
| | | |
| | | |
| | | driverHomeVO.setPlatformJobList(platformJobList); |
| | | |
| | | // 园区导览图 图片 |
| | | driverHomeVO.setReservationMap(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.PLATFORM_GUIDEMAP).getCode()); |
| | | // 预约指南 文本 |
| | | driverHomeVO.setBookingTips(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.PLATFORM_BOOKING_TIPS).getCode()); |
| | | |
| | | return driverHomeVO; |
| | | } |
| | |
| | | } |
| | | }else if( Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WAIT_CALL.getKey()) |
| | | || Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.IN_WAIT.getKey()) |
| | | ){//查询排队情况 |
| | | Long lineUpNum = platformJobMapper.selectCount(new QueryWrapper<PlatformJob>().lambda() |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO) |
| | | .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WAIT_CALL.getKey() |
| | | ,Constants.PlatformJobStatus.IN_WAIT.getKey() |
| | | ,Constants.PlatformJobStatus.TRANSFERING.getKey()) |
| | | .gt(PlatformJob::getSignDate,platformJob.getSignDate()) |
| | | .like(PlatformJob::getArriveDate,DateUtil.getDate(platformJob.getArriveDate(),"yyyy-MM-dd"))); |
| | | platformJob.setLineUpNum(lineUpNum); |
| | | ){ |
| | | //查询前方排队数量 |
| | | this.queryWaitNum(platformJob); |
| | | }else if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){ |
| | | //作业月台信息 |
| | | Platform platform = platformMapper.selectById(platformJob.getPlatformId()); |
| | | Platform platform = platformJoinMapper.selectById(platformJob.getPlatformId()); |
| | | if(Objects.nonNull(platform)){ |
| | | platformJob.setPlatformName(platform.getName()); |
| | | } |
| | |
| | | ); |
| | | //获取所有月台组 |
| | | List<Integer> platformIdList = platformJobList.stream().map(m->m.getPlatformGroupId()).collect(Collectors.toList()); |
| | | List<Platform> platformList = platformMapper.selectList(new QueryWrapper<Platform>().lambda() |
| | | List<Platform> platformList = platformJoinMapper.selectList(new QueryWrapper<Platform>().lambda() |
| | | .eq(Platform::getIsdeleted,Constants.ZERO) |
| | | .in(Platform::getId,platformIdList)); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Platform> getPlatformList(Integer groupId, LoginUserInfo loginUserInfo){ |
| | | //查询月台组下所有月台 |
| | | List<Platform> allPlatformList = platformJoinMapper.selectJoinList(Platform.class, |
| | | new MPJLambdaWrapper<Platform>() |
| | | .selectAll(Platform.class) |
| | | .select(" ( select count(1) from platform_job pj where t.id = pj.PLATFORM_ID and pj.STATUS = "+Constants.PlatformJobStatus.WORKING.getKey()+" ) as workStatus ") |
| | | .eq(Platform::getIsdeleted, Constants.ZERO) |
| | | .eq(Platform::getStatus,Constants.ZERO) |
| | | .eq(Platform::getGroupId,groupId) |
| | | ); |
| | | this.getPlatformShow(allPlatformList,loginUserInfo); |
| | | for (Platform platform:allPlatformList) { |
| | | this.getJobByPlatform(platform,loginUserInfo); |
| | | } |
| | | return allPlatformList; |
| | | } |
| | | |
| | | /** |
| | | * 查询月台的开启情况 |
| | | * @param allPlatformList |
| | | * @param loginUserInfo |
| | | */ |
| | | public void getPlatformShow(List<Platform> allPlatformList , LoginUserInfo loginUserInfo){ |
| | | //处理我的月台信息 是否配置隐藏 |
| | | List<PlatformShowParam> platformShowParamList = platformShowParamMapper.selectList(new QueryWrapper<PlatformShowParam>() |
| | | .lambda() |
| | | .eq(PlatformShowParam::getIsdeleted, Constants.ZERO) |
| | | .eq(PlatformShowParam::getMemberId,loginUserInfo.getMemberId()) |
| | | ); |
| | | //如果未配置该数据 则全部显示 |
| | | if(CollectionUtils.isEmpty(platformShowParamList)){ |
| | | for (Platform platform:allPlatformList) { |
| | | platform.setShowConfig(true); |
| | | } |
| | | }else{ |
| | | //根据配置显示数据 |
| | | for (PlatformShowParam platformShowParam:platformShowParamList) { |
| | | for (Platform platform:allPlatformList) { |
| | | if(Constants.equalsInteger(platform.getId(),platformShowParam.getPlatformId())){ |
| | | platform.setShowConfig(true); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取月台下的任务列表 |
| | | * @param platform |
| | | * @param loginUserInfo |
| | | */ |
| | | public void getJobByPlatform(Platform platform,LoginUserInfo loginUserInfo){ |
| | | List<PlatformJob> platformJobList = platformJobJoinMapper.selectJoinList(PlatformJob.class,new MPJLambdaWrapper<PlatformJob>() |
| | | .selectAll(PlatformJob.class) |
| | | .selectAs(Platform::getName,PlatformJob::getPlatformName) |
| | | .selectAs(Platform::getWorkRate,PlatformJob::getWorkRate) |
| | | .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId) |
| | | .eq(PlatformJob::getPlatformId,platform.getId()) |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformJob::getDrivierPhone,loginUserInfo.getMobile()) |
| | | .like(PlatformJob::getArriveDate, DateUtil.getCurrDate()) |
| | | .orderByDesc(PlatformJob::getId) |
| | | ); |
| | | for (PlatformJob platformJob:platformJobList) { |
| | | //处理WSM数量 |
| | | this.getWmsJobData(platformJob); |
| | | //查询前方排队数量 |
| | | this.queryWaitNum(platformJob); |
| | | } |
| | | platform.setWorkJobList(platformJobList); |
| | | } |
| | | |
| | | } |