| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.DeviceMapper; |
| | | import com.doumee.dao.business.PlatformDeviceMapper; |
| | | import com.doumee.dao.business.PlatformJobMapper; |
| | | import com.doumee.dao.business.PlatformMapper; |
| | | import com.doumee.dao.business.join.PlatformJobJoinMapper; |
| | | import com.doumee.dao.business.join.PlatformJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.openapi.response.PlatformNumByStatusResponse; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private PlatformDeviceMapper platformDeviceMapper; |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | @Autowired |
| | | private PlatformJobJoinMapper platformJobJoinMapper; |
| | | |
| | | |
| | | |
| | |
| | | ); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return platformPageData; |
| | | } |
| | | |
| | | @Override |
| | | public List<Platform> platformWorkReportList(Platform platform) { |
| | | if(Objects.isNull(platform) |
| | | || Objects.isNull(platform.getQueryDateStart()) |
| | | || Objects.isNull(platform.getQueryDateEnd())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"参数错误"); |
| | | } |
| | | MPJLambdaWrapper<Platform> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Platform.class) |
| | | .selectAs(PlatformGroup::getName,Platform::getGroupName) |
| | | .select(" (select ifnull(TIMESTAMPDIFF(HOUR, '2023-01-01 '||pg.start_time||':00', '2023-01-01 '||pg.end_time||':00' ),0) from platform_group pg " + |
| | | " where t.group_id = pg.id ) as openTime ") |
| | | .leftJoin(PlatformGroup.class,PlatformGroup::getId,Platform::getGroupId); |
| | | queryWrapper |
| | | .eq(platform.getGroupId() != null, Platform::getGroupId, platform.getGroupId()) |
| | | .eq( Platform::getIsdeleted, Constants.ZERO) |
| | | .like(platform.getName() != null, Platform::getName, platform.getName()) |
| | | .orderByDesc(Platform::getId); |
| | | List<Platform> platformList = platformJoinMapper.selectList(queryWrapper); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformList)){ |
| | | //查询所有月台数据下的 任务数据 任务数据为 |
| | | List<PlatformJob> platformJobList = platformJobJoinMapper.selectJoinList(PlatformJob.class, |
| | | new MPJLambdaWrapper<PlatformJob>() |
| | | .selectAll(PlatformJob.class) |
| | | .select(" ( select ROUND( ifnull(SUM(pl.PARAM3),0) / 3600 , 2 ) from platform_log pl where pl.OBJ_ID = t.id " + |
| | | " ) as workTimes ") |
| | | .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WORKING.getKey(), |
| | | Constants.PlatformJobStatus.DONE.getKey(), |
| | | Constants.PlatformJobStatus.TRANSFERING.getKey(), |
| | | Constants.PlatformJobStatus.EXCEPTION.getKey(), |
| | | Constants.PlatformJobStatus.AUTHED_LEAVE.getKey(), |
| | | Constants.PlatformJobStatus.LEAVED.getKey() |
| | | ) |
| | | .in(PlatformJob::getPlatformId,platformList.stream().map(i->i.getId()).collect(Collectors.toList())) |
| | | .ge(platform.getQueryDateStart() != null, PlatformJob::getStartDate, Utils.Date.getStart(platform.getQueryDateStart())) |
| | | .le(platform.getQueryDateEnd() != null, PlatformJob::getStartDate, Utils.Date.getEnd(platform.getQueryDateEnd())) |
| | | ); |
| | | //查询2日期相差天数 |
| | | Integer sumDays = DateUtil.daysBetweenDates(platform.getQueryDateStart(),platform.getQueryDateEnd()); |
| | | for (Platform bean:platformList) { |
| | | List<PlatformJob> beanJobList = platformJobList.stream().filter(i->Constants.equalsInteger(i.getPlatformId(),bean.getId())).collect(Collectors.toList()); |
| | | bean.setStopCount(beanJobList.size()); |
| | | bean.setWorkCountTime( |
| | | beanJobList.stream().map(i->i.getWorkTimes()).reduce(BigDecimal.ZERO,BigDecimal::add) |
| | | ); |
| | | if(Objects.isNull(bean.getOpenTime())||bean.getOpenTime().compareTo(BigDecimal.ZERO)<=0){ |
| | | bean.setUseRata(BigDecimal.ZERO); |
| | | continue; |
| | | } |
| | | BigDecimal sumTime = BigDecimal.valueOf(sumDays).multiply(bean.getOpenTime()); |
| | | bean.setUseRata( |
| | | bean.getWorkCountTime().divide(sumTime,BigDecimal.ROUND_HALF_DOWN,2) |
| | | ); |
| | | } |
| | | } |
| | | return platformList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(Constants.equalsInteger(platform.getPlatformStatus(),Constants.ONE)){ |
| | | response.setCarCode(platform.getWorkCarCode()); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | return platformStatusListResponses; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |