From bfd87d12adb1d511334cd91cf6c7ff3608fae8b9 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期三, 09 十月 2024 16:30:38 +0800 Subject: [PATCH] 最新版本 --- server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java | 99 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 97 insertions(+), 2 deletions(-) diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java index 893331c..5bdab14 100644 --- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java +++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java @@ -7,13 +7,17 @@ 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 com.doumee.dao.openapi.response.PlatformStatusListResponse; import com.doumee.service.business.PlatformDeviceService; import com.doumee.service.business.PlatformService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -28,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -47,6 +52,8 @@ private PlatformDeviceMapper platformDeviceMapper; @Autowired private DeviceMapper deviceMapper; + @Autowired + private PlatformJobJoinMapper platformJobJoinMapper; @@ -72,6 +79,7 @@ platformDevice.setType(Constants.ZERO); platformDevice.setDeviceId(ledId.toString()); platformDevice.setHkId(device.getHkId()); + platformDevice.setHkNo(device.getNo()); platformDevice.setName(device.getName()); platformDeviceList.add(platformDevice); } @@ -93,6 +101,7 @@ platformDevice.setType(Constants.TWO); platformDevice.setDeviceId(broadcastId.toString()); platformDevice.setHkId(device.getHkId()); + platformDevice.setHkNo(device.getNo()); platformDevice.setName(device.getName()); platformDeviceList.add(platformDevice); } @@ -147,6 +156,7 @@ platformDevice.setType(Constants.ZERO); platformDevice.setDeviceId(ledId.toString()); platformDevice.setHkId(device.getHkId()); + platformDevice.setHkNo(device.getNo()); platformDevice.setName(device.getName()); platformDeviceList.add(platformDevice); } @@ -170,6 +180,7 @@ platformDevice.setType(Constants.TWO); platformDevice.setDeviceId(broadcastId.toString()); platformDevice.setHkId(device.getHkId()); + platformDevice.setHkNo(device.getNo()); platformDevice.setName(device.getName()); platformDeviceList.add(platformDevice); } @@ -293,10 +304,64 @@ ); } } - } - 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 ") + .select(" ( select ROUND( ifnull(SUM(pl.PARAM3),0) / 3600 , 2 ) from platform_log pl where pl.remark = t.id " + + " and pl.CREATE_DATE > '"+DateUtil.getFomartDate(platform.getQueryDateStart(),"yyyy-MM-dd")+" 00:00:00' " + + "and pl.CREATE_DATE <= '"+DateUtil.getFomartDate(platform.getQueryDateEnd(),"yyyy-MM-dd")+" 23:59:59' ) as workCountTime ") + .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) + .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.getQueryDateEnd(),platform.getQueryDateStart())+1; + for (Platform bean:platformList) { + List<PlatformJob> beanJobList = platformJobList.stream().filter(i->Constants.equalsInteger(i.getPlatformId(),bean.getId())).collect(Collectors.toList()); + bean.setStopCount(beanJobList.size()); + 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().multiply(new BigDecimal(100)).divide(sumTime,BigDecimal.ROUND_HALF_DOWN,2) + ); + } + } + return platformList; } @Override @@ -333,6 +398,36 @@ + @Override + public List<PlatformStatusListResponse> getPlatformStatusList(){ + List<Platform> platformList = 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 ") + .select(" ( select pj.CAR_CODE_FRONT from platform_job pj where t.id = pj.PLATFORM_ID and pj.STATUS = "+Constants.PlatformJobStatus.WORKING.getKey()+" limit 1 ) as workCarCode ") + .eq(Platform::getIsdeleted,Constants.ZERO) + ); + List<PlatformStatusListResponse> platformStatusListResponses = new ArrayList<>(); + if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformList)){ + for (Platform platform:platformList) { + PlatformStatusListResponse response = new PlatformStatusListResponse(); + response.setPlatformHkId(platform.getHkId()); + response.setPlatformName(platform.getName()); + response.setStatus(platform.getPlatformStatus()); + if(Constants.equalsInteger(platform.getPlatformStatus(),Constants.ONE)){ + response.setCarCode(platform.getWorkCarCode()); + } + platformStatusListResponses.add(response); + } + } + return platformStatusListResponses; + } + + + + + + + } -- Gitblit v1.9.3