|
@@ -31,6 +31,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -63,6 +64,36 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
|
|
|
private AlipayDeviceService alipayDeviceService;
|
|
|
|
|
|
+ @PostMapping("count")
|
|
|
+ @ApiOperation("查询条数")
|
|
|
+ public R<List<DeviceAlgorithmChargingDto.CountVo>> count(@RequestBody @Validated DeviceAlgorithmChargingDto.Count count) {
|
|
|
+ //默认值
|
|
|
+ List<Long> deviceIds = count.getDeviceIds();
|
|
|
+ JList<DeviceAlgorithmChargingDto.CountVo> countVos = new JArrayList<>(deviceIds.size());
|
|
|
+ deviceIds.forEach(deviceId -> {
|
|
|
+ DeviceAlgorithmChargingDto.CountVo countVo = new DeviceAlgorithmChargingDto.CountVo()
|
|
|
+ .setDeviceId(deviceId)
|
|
|
+ .setCount(0);
|
|
|
+ countVos.add(countVo);
|
|
|
+ });
|
|
|
+ JMap<Long, DeviceAlgorithmChargingDto.CountVo> cover = countVos.toMap(DeviceAlgorithmChargingDto.CountVo::getDeviceId).cover();
|
|
|
+ //查询数据
|
|
|
+ String thisTime = DataTime.getSring("yyyyMMdd");
|
|
|
+ List<DeviceAlgorithmCharging> list = list(new LambdaQueryWrapper<DeviceAlgorithmCharging>()
|
|
|
+ .in(DeviceAlgorithmCharging::getDeviceId, deviceIds)
|
|
|
+ .gt(DeviceAlgorithmCharging::getUnusedSize, 0)
|
|
|
+ .and(deviceAlgorithmChargingLambdaQueryWrapper -> deviceAlgorithmChargingLambdaQueryWrapper
|
|
|
+ .eq(DeviceAlgorithmCharging::getTimeout, -1)
|
|
|
+ .or()
|
|
|
+ .ge(DeviceAlgorithmCharging::getTimeout, thisTime)
|
|
|
+ )
|
|
|
+ .le(DeviceAlgorithmCharging::getBeginTime, thisTime)
|
|
|
+ );
|
|
|
+ JMap<Long, List<DeviceAlgorithmCharging>> group = new JArrayList<>(list).toMap(DeviceAlgorithmCharging::getDeviceId).group();
|
|
|
+ group.forEach((deviceId, deviceAlgorithmChargings) -> cover.get(deviceId).setCount(deviceAlgorithmChargings.size()));
|
|
|
+ return R.ok(countVos);
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("page")
|
|
|
@ApiOperation("分页查询")
|
|
|
public R<PageBean<DeviceAlgorithmChargingDto.Vo>> page(@RequestBody @Validated DeviceAlgorithmChargingDto.Page page) {
|