k94314517
2024-10-16 17efddc6a667670dca682bf36b51a43e99615e6d
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java
@@ -9,10 +9,7 @@
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.*;
import com.doumee.dao.business.join.PlatformJobJoinMapper;
import com.doumee.dao.business.join.PlatformJoinMapper;
import com.doumee.dao.business.model.*;
@@ -46,6 +43,8 @@
    @Autowired
    private PlatformMapper platformMapper;
    @Autowired
    private PlatformGroupMapper platformGroupMapper;
    @Autowired
    private PlatformJoinMapper platformJoinMapper;
    @Autowired
@@ -135,6 +134,28 @@
    public void updateById(Platform platform) {
        platform.setEditor(platform.getLoginUserInfo().getId());
        platform.setEditDate(new Date());
        Platform model = platformMapper.selectById(platform.getId());
        if(model ==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(model.getGroupId()!= null && platform.getGroupId()!=null && !Constants.equalsInteger(platform.getGroupId(),model.getGroupId())){
            PlatformGroup group = platformGroupMapper.selectById(platform.getGroupId());
            if(group ==null || Constants.equalsInteger(group.getIsdeleted(),Constants.ONE)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,月台组信息不正确!");
            }
            //如果月台分组发生变化
            Long count =  platformJobJoinMapper.selectCount(  new QueryWrapper<PlatformJob>().lambda()
                    .eq(PlatformJob::getIsdeleted,Constants.ZERO)
                    .notIn(PlatformJob::getStatus,Constants.PlatformJobStatus.WART_SIGN_IN.getKey()
                            ,Constants.PlatformJobStatus.WAIT_CONFIRM.getKey()
                            ,Constants.PlatformJobStatus.DONE.getKey()
                            ,Constants.PlatformJobStatus.LEAVED.getKey()
                            ,Constants.PlatformJobStatus.CANCEL.getKey()
                    ));
            if(count!=null && count>0){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,当前月台有正在作业的任务,不能进行月台组切换操作!");
            }
        }
        //删除LED/广播数据
        platformDeviceMapper.delete(new QueryWrapper<PlatformDevice>().lambda()
                .eq(PlatformDevice::getPlatformId,platform.getId())
@@ -320,9 +341,12 @@
                .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.OBJ_ID = t.id and pl.remark = t.id  " +
                        " and pl.CREATE_DATE > '"+Utils.Date.getStart(platform.getQueryDateStart())+"'  " +
                        "and pl.CREATE_DATE <=  '"+Utils.Date.getEnd(platform.getQueryDateEnd())+"'  ) as workCountTime ")
                .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 ")
                .select(" ( select count(1)  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' and pl.OBJ_TYPE = 5  ) as stopCount ")
                .leftJoin(PlatformGroup.class,PlatformGroup::getId,Platform::getGroupId);
        queryWrapper
                .eq(platform.getGroupId() != null, Platform::getGroupId, platform.getGroupId())
@@ -349,8 +373,6 @@
            //查询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;
@@ -416,6 +438,7 @@
                if(Constants.equalsInteger(platform.getPlatformStatus(),Constants.ONE)){
                    response.setCarCode(platform.getWorkCarCode());
                }
                platformStatusListResponses.add(response);
            }
        }
        return platformStatusListResponses;