jiangping
2024-11-23 c9aa84299c67f0b17585ef58c9c586f76a8a4796
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
package com.doumee.service.business.impl;
 
import cn.emay.sdk.util.StringUtil;
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.DateUtil;
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.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;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
 
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 月台信息表Service实现
 * @author 江蹄蹄
 * @date 2024/06/28 10:03
 */
@Service
public class PlatformServiceImpl implements PlatformService {
 
    @Autowired
    private PlatformMapper platformMapper;
    @Autowired
    private PlatformGroupMapper platformGroupMapper;
    @Autowired
    private PlatformJoinMapper platformJoinMapper;
    @Autowired
    private PlatformDeviceMapper platformDeviceMapper;
    @Autowired
    private DeviceMapper deviceMapper;
    @Autowired
    private PlatformJobJoinMapper platformJobJoinMapper;
 
 
 
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public Integer create(Platform platform) {
        platform.setCreateDate(new Date());
        platform.setIsdeleted(Constants.ZERO);
        platform.setCreator(platform.getLoginUserInfo().getId());
        platformMapper.insert(platform);
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getLedIds())){
            List<PlatformDevice> platformDeviceList = new ArrayList<>();
            for (Integer ledId:platform.getLedIds()) {
                Device device = deviceMapper.selectById(ledId);
                if(Objects.isNull(device)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到led设备信息【"+ledId+"】");
                }
                PlatformDevice platformDevice = new PlatformDevice();
                platformDevice.setIsdeleted(Constants.ZERO);
                platformDevice.setPlatformId(platform.getId());
                platformDevice.setCreateDate(new Date());
                platformDevice.setCreator(platform.getLoginUserInfo().getId());
                platformDevice.setType(Constants.ZERO);
                platformDevice.setDeviceId(ledId.toString());
                platformDevice.setHkId(device.getHkId());
                platformDevice.setHkNo(device.getNo());
                platformDevice.setName(device.getName());
                platformDeviceList.add(platformDevice);
            }
            platformDeviceMapper.insert(platformDeviceList);
        }
 
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getBroadcastIds())){
            List<PlatformDevice> platformDeviceList = new ArrayList<>();
            for (Integer broadcastId:platform.getBroadcastIds()) {
                Device device = deviceMapper.selectById(broadcastId);
                if(Objects.isNull(device)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到广播设备信息【"+broadcastId+"】");
                }
                PlatformDevice platformDevice = new PlatformDevice();
                platformDevice.setIsdeleted(Constants.ZERO);
                platformDevice.setPlatformId(platform.getId());
                platformDevice.setCreateDate(new Date());
                platformDevice.setCreator(platform.getLoginUserInfo().getId());
                platformDevice.setType(Constants.TWO);
                platformDevice.setDeviceId(broadcastId.toString());
                platformDevice.setHkId(device.getHkId());
                platformDevice.setHkNo(device.getNo());
                platformDevice.setName(device.getName());
                platformDeviceList.add(platformDevice);
            }
            platformDeviceMapper.insert(platformDeviceList);
        }
 
        return platform.getId();
    }
 
    @Override
    public void deleteById(Integer id) {
        platformMapper.deleteById(id);
    }
 
    @Override
    public void delete(Platform platform) {
        UpdateWrapper<Platform> deleteWrapper = new UpdateWrapper<>(platform);
        platformMapper.delete(deleteWrapper);
    }
 
    @Override
    public void deleteByIdInBatch(List<Integer> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return;
        }
        platformMapper.deleteBatchIds(ids);
    }
 
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    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())
                .in(PlatformDevice::getType,Constants.ZERO,Constants.TWO)
        );
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getLedIds())){
            List<PlatformDevice> platformDeviceList = new ArrayList<>();
            String ledNames = "";
            for (Integer ledId:platform.getLedIds()) {
                Device device = deviceMapper.selectById(ledId);
                if(Objects.isNull(device)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到led设备信息【"+ledId+"】");
                }
                PlatformDevice platformDevice = new PlatformDevice();
                platformDevice.setIsdeleted(Constants.ZERO);
                platformDevice.setPlatformId(platform.getId());
                platformDevice.setCreateDate(new Date());
                platformDevice.setCreator(platform.getLoginUserInfo().getId());
                platformDevice.setType(Constants.ZERO);
                platformDevice.setDeviceId(ledId.toString());
                platformDevice.setHkId(device.getHkId());
                platformDevice.setHkNo(device.getNo());
                platformDevice.setName(device.getName());
                platformDeviceList.add(platformDevice);
            }
            platformDeviceMapper.insert(platformDeviceList);
            platform.setLedNames(ledNames);
        }
 
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getBroadcastIds())){
            List<PlatformDevice> platformDeviceList = new ArrayList<>();
            String ledNames = "";
            for (Integer broadcastId:platform.getBroadcastIds()) {
                Device device = deviceMapper.selectById(broadcastId);
                if(Objects.isNull(device)){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到广播设备信息【"+broadcastId+"】");
                }
                PlatformDevice platformDevice = new PlatformDevice();
                platformDevice.setIsdeleted(Constants.ZERO);
                platformDevice.setPlatformId(platform.getId());
                platformDevice.setCreateDate(new Date());
                platformDevice.setCreator(platform.getLoginUserInfo().getId());
                platformDevice.setType(Constants.TWO);
                platformDevice.setDeviceId(broadcastId.toString());
                platformDevice.setHkId(device.getHkId());
                platformDevice.setHkNo(device.getNo());
                platformDevice.setName(device.getName());
                platformDeviceList.add(platformDevice);
            }
            platformDeviceMapper.insert(platformDeviceList);
        }
 
        platformMapper.updateById(platform);
    }
 
    @Override
    public void updateStatusById(Platform platform) {
        Platform model  =platformMapper.selectById(platform.getId());
        if(model ==null) {
            throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该记录信息不存在!");
        }
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(loginUserInfo == null){
            loginUserInfo = platform.getLoginUserInfo();
        }
        Platform update = new Platform();
        update.setId(model.getId());
        update.setEditDate(new Date());
        update.setEditor(loginUserInfo.getId());
        update.setStatus(platform.getStatus());
        platformMapper.updateById(update);
    }
 
    @Override
    public void updateByIdInBatch(List<Platform> platforms) {
        if (CollectionUtils.isEmpty(platforms)) {
            return;
        }
        for (Platform platform: platforms) {
            this.updateById(platform);
        }
    }
 
    @Override
    public Platform findById(Integer id) {
        return platformMapper.selectById(id);
    }
 
    @Override
    public Platform findOne(Platform platform) {
        QueryWrapper<Platform> wrapper = new QueryWrapper<>(platform);
        return platformMapper.selectOne(wrapper);
    }
 
    @Override
    public List<Platform> findList(Platform platform) {
        QueryWrapper<Platform> wrapper = new QueryWrapper<>(platform);
        return platformMapper.selectList(wrapper);
    }
  
    @Override
    public PageData<Platform> findPage(PageWrap<Platform> pageWrap) {
        IPage<Platform> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        MPJLambdaWrapper<Platform> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(Platform.class)
                    .selectAs(PlatformGroup::getName,Platform::getGroupName)
                    .leftJoin(PlatformGroup.class,PlatformGroup::getId,Platform::getGroupId);
        Utils.MP.blankToNull(pageWrap.getModel());
        pageWrap.getModel().setIsdeleted(Constants.ZERO);
        queryWrapper
                .eq(pageWrap.getModel().getId() != null, Platform::getId, pageWrap.getModel().getId())
                .eq(pageWrap.getModel().getCreator() != null, Platform::getCreator, pageWrap.getModel().getCreator())
                .ge(pageWrap.getModel().getCreateDate() != null, Platform::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()))
                .le(pageWrap.getModel().getCreateDate() != null, Platform::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()))
                .eq(pageWrap.getModel().getEditor() != null, Platform::getEditor, pageWrap.getModel().getEditor())
                .ge(pageWrap.getModel().getEditDate() != null, Platform::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()))
                .le(pageWrap.getModel().getEditDate() != null, Platform::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()))
                .eq(pageWrap.getModel().getIsdeleted() != null, Platform::getIsdeleted, pageWrap.getModel().getIsdeleted())
                .like(pageWrap.getModel().getName() != null, Platform::getName, pageWrap.getModel().getName())
                .eq(pageWrap.getModel().getRemark() != null, Platform::getRemark, pageWrap.getModel().getRemark())
                .eq(pageWrap.getModel().getStatus() != null, Platform::getStatus, pageWrap.getModel().getStatus())
                .eq(pageWrap.getModel().getSortnum() != null, Platform::getSortnum, pageWrap.getModel().getSortnum())
                .eq(pageWrap.getModel().getGroupId() != null, Platform::getGroupId, pageWrap.getModel().getGroupId())
                .eq(pageWrap.getModel().getStartTime() != null, Platform::getStartTime, pageWrap.getModel().getStartTime())
                .eq(pageWrap.getModel().getEndTime() != null, Platform::getEndTime, pageWrap.getModel().getEndTime())
                .eq(pageWrap.getModel().getWorkingNum() != null, Platform::getWorkingNum, pageWrap.getModel().getWorkingNum())
                .ge(pageWrap.getModel().getLastEventTime() != null, Platform::getLastEventTime, Utils.Date.getStart(pageWrap.getModel().getLastEventTime()))
                .le(pageWrap.getModel().getLastEventTime() != null, Platform::getLastEventTime, Utils.Date.getEnd(pageWrap.getModel().getLastEventTime()))
                .eq(pageWrap.getModel().getDeviceNames() != null, Platform::getDeviceNames, pageWrap.getModel().getDeviceNames())
                .eq(pageWrap.getModel().getScreenName() != null, Platform::getScreenName, pageWrap.getModel().getScreenName())
                .eq(pageWrap.getModel().getHkId() != null, Platform::getHkId, pageWrap.getModel().getHkId())
                .eq(pageWrap.getModel().getCompanys() != null, Platform::getCompanys, pageWrap.getModel().getCompanys())
                .eq(pageWrap.getModel().getXpos() != null, Platform::getXpos, pageWrap.getModel().getXpos())
                .eq(pageWrap.getModel().getYpos() != null, Platform::getYpos, pageWrap.getModel().getYpos())
                .eq(pageWrap.getModel().getWidth() != null, Platform::getWidth, pageWrap.getModel().getWidth())
                .eq(pageWrap.getModel().getHeight() != null, Platform::getHeight, pageWrap.getModel().getHeight())
                .eq(pageWrap.getModel().getAngle() != null, Platform::getAngle, pageWrap.getModel().getAngle());
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        PageData<Platform> platformPageData = PageData.from(platformMapper.selectJoinPage(page,Platform.class, queryWrapper));
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformPageData.getRecords())){
            for (Platform platform:platformPageData.getRecords()) {
                List<PlatformDevice> ledDevice =  platformDeviceMapper.selectList(new QueryWrapper<PlatformDevice>().lambda()
                        .eq(PlatformDevice::getPlatformId,platform.getId())
                        .eq(PlatformDevice::getType,Constants.ZERO)
                );
                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ledDevice)){
                    platform.setLedNames(String.join(",", ledDevice.stream().map(m->m.getName()).collect(Collectors.toList())));
                    platform.setLedIds(
                            ledDevice.stream().map(m->Integer.valueOf(m.getDeviceId())).collect(Collectors.toList())
                    );
                }
 
                List<PlatformDevice> broadcastDevice =  platformDeviceMapper.selectList(new QueryWrapper<PlatformDevice>().lambda()
                        .eq(PlatformDevice::getPlatformId,platform.getId())
                        .eq(PlatformDevice::getType,Constants.TWO)
                );
                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(broadcastDevice)){
                    platform.setBroadcastNames(String.join(",", broadcastDevice.stream().map(m->m.getName()).collect(Collectors.toList())));
                    platform.setBroadcastIds(
                            broadcastDevice.stream().map(m->Integer.valueOf(m.getDeviceId())).collect(Collectors.toList())
                    );
                }
            }
        }
        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 ")
                .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())
                .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) {
                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)
                );
                bean.setUseRata(Constants.formatBigdecimal2Float(bean.getUseRata()));//强制保留两位小数
            }
        }
        return platformList;
    }
 
    @Override
    public long count(Platform platform) {
        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;
    }
 
 
 
    @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;
    }
 
 
 
 
 
 
 
 
 
}