|
@@ -105,6 +105,27 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
private final DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
|
|
|
|
|
|
+ @PostMapping("eventList")
|
|
|
+ @ApiOperation("根据事件编码查询设备")
|
|
|
+ public R<List<DeviceInfoDto.EventListVo>> eventList(@RequestBody @Validated DeviceInfoDto.EventList eventList) {
|
|
|
+ String countAs = "id";
|
|
|
+ QueryWrapper<DeviceEventMsg> queryWrapper = new QueryWrapper<DeviceEventMsg>()
|
|
|
+ .select(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId) + "as " + LambdaUtils.getProperty(DeviceEventMsg::getDeviceId), "count(*) as " + countAs)
|
|
|
+ .eq(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getCode), eventList.getCode())
|
|
|
+ .groupBy(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId))
|
|
|
+ .last(countAs + " >= " + eventList.getSize());
|
|
|
+ List<DeviceEventMsg> list = deviceEventMsgService.list(queryWrapper);
|
|
|
+ if(!Emptys.check(list)) {
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ List<DeviceInfo> deviceInfos = listByIds(new JArrayList<>(list).getProperty(DeviceEventMsg::getDeviceId));
|
|
|
+ List<DeviceInfoDto.EventListVo> eventListVos = copy(DeviceInfoDto.EventListVo.class, deviceInfos);
|
|
|
+ List<DeviceInfoDto.EventListVo> builder = copy(eventListVos)
|
|
|
+ .target(list, DeviceInfoDto.EventListVo::getDeviceId, DeviceInfoDto.EventListVo::getSize, DeviceEventMsg::getDeviceId, DeviceEventMsg::getId)
|
|
|
+ .builder();
|
|
|
+ return R.ok(builder);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@ApiOperation("点位设备数量查询")
|
|
|
@Override
|