|
@@ -4,10 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xy.dto.DeviceChargingHistoryDto;
|
|
|
-import com.xy.dto.DeviceInfoDto;
|
|
|
import com.xy.entity.DeviceChargingHistory;
|
|
|
import com.xy.mapper.DeviceChargingHistoryMapper;
|
|
|
-import com.xy.utils.Emptys;
|
|
|
+import com.xy.utils.MybatisPlusQuery;
|
|
|
import com.xy.utils.PageBean;
|
|
|
import com.xy.utils.PlusBeans;
|
|
|
import com.xy.utils.R;
|
|
@@ -15,11 +14,6 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
|
|
|
import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
|
|
@@ -36,22 +30,11 @@ import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
@Api(tags = "设备计费历史表")
|
|
|
public class DeviceChargingHistoryServiceImpl extends ServiceImpl<DeviceChargingHistoryMapper, DeviceChargingHistory> implements DeviceChargingHistoryService {
|
|
|
|
|
|
- private DeviceInfoServiceImpl deviceInfoService;
|
|
|
-
|
|
|
- @PostMapping("page")
|
|
|
+ @Override
|
|
|
@ApiOperation("分页查询")
|
|
|
- public R<PageBean<DeviceChargingHistoryDto.PageVo>> page(@RequestBody @Validated DeviceChargingHistoryDto.Page page) {
|
|
|
- //查询设备计费历史
|
|
|
- LambdaQueryWrapper<DeviceChargingHistory> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceChargingHistory>().eq(DeviceChargingHistory::getDeviceId, page.getDeviceId());
|
|
|
+ public R<PageBean<DeviceChargingHistoryDto.Vo>> page(DeviceChargingHistoryDto.Page page) {
|
|
|
+ LambdaQueryWrapper<DeviceChargingHistory> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, DeviceChargingHistory.class).build();
|
|
|
IPage<DeviceChargingHistory> iPage = page(PlusBeans.toIPage(page.getPage()), lambdaQueryWrapper);
|
|
|
- PageBean<DeviceChargingHistoryDto.PageVo> pageVoPageBean = toPageBean(DeviceChargingHistoryDto.PageVo.class, iPage);
|
|
|
- List<DeviceChargingHistoryDto.PageVo> records = pageVoPageBean.getRecords();
|
|
|
- if (!Emptys.check(records)) {
|
|
|
- return R.ok(pageVoPageBean);
|
|
|
- }
|
|
|
- //查询设备信息
|
|
|
- DeviceInfoDto.Vo deviceInfo = deviceInfoService.obj(new DeviceInfoDto.Obj().setDeviceId(page.getDeviceId())).getData();
|
|
|
- records.forEach(pageVo -> pageVo.setDeviceInfo(deviceInfo));
|
|
|
- return R.ok(pageVoPageBean);
|
|
|
+ return R.ok(toPageBean(DeviceChargingHistoryDto.Vo.class, iPage));
|
|
|
}
|
|
|
}
|