k94314517
2024-08-30 6b9a7ae981171c1bb6ff6c7d6d0c0103ed1f9348
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java
@@ -8,9 +8,11 @@
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.PlatformMapper;
import com.doumee.dao.business.join.PlatformJoinMapper;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.Platform;
import com.doumee.dao.business.model.PlatformGroup;
import com.doumee.dao.openapi.response.PlatformNumByStatusResponse;
import com.doumee.service.business.PlatformService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -24,6 +26,7 @@
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 月台信息表Service实现
@@ -35,6 +38,8 @@
    @Autowired
    private PlatformMapper platformMapper;
    @Autowired
    private PlatformJoinMapper platformJoinMapper;
    @Override
    public Integer create(Platform platform) {
@@ -65,6 +70,7 @@
    public void updateById(Platform platform) {
        platformMapper.updateById(platform);
    }
    @Override
    public void updateStatusById(Platform platform) {
        Platform model  =platformMapper.selectById(platform.getId());
@@ -162,4 +168,35 @@
        QueryWrapper<Platform> wrapper = new QueryWrapper<>(platform);
        return platformMapper.selectCount(wrapper);
    }
    @Override
    public PlatformNumByStatusResponse getPlatformNumByStatusResponse(){
        PlatformNumByStatusResponse platformNumByStatusResponse = new PlatformNumByStatusResponse();
        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 ")
                .eq(Platform::getIsdeleted,Constants.ZERO)
        );
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformList)){
            //停用数量
            platformNumByStatusResponse.setForbiddenNum(
                    platformList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.ONE)).collect(Collectors.toList()).size()
            );
            //工作数量
            platformNumByStatusResponse.setUsingNum(
                    platformList.stream().filter(i->i.getWorkStatus()>Constants.ZERO).collect(Collectors.toList()).size()
            );
            //空闲数量
            platformNumByStatusResponse.setIdleNum(
                    platformList.stream().filter(i->i.getWorkStatus()<=Constants.ZERO).collect(Collectors.toList()).size()
            );
        }
        return platformNumByStatusResponse;
    }
}