2024-07-08 17:47:02 +08:00
|
|
|
package com.gunshi.project.xyt.controller;
|
|
|
|
|
|
2024-07-10 14:04:43 +08:00
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.core.result.R;
|
2024-07-10 14:04:43 +08:00
|
|
|
import com.gunshi.project.xyt.entity.vo.StWaterRVo;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.model.StWaterR;
|
|
|
|
|
import com.gunshi.project.xyt.service.StWaterRService;
|
2024-07-10 14:04:43 +08:00
|
|
|
import com.gunshi.project.xyt.util.ConvertUtil;
|
|
|
|
|
import com.gunshi.project.xyt.util.DateUtil;
|
|
|
|
|
import com.gunshi.project.xyt.util.ExcelUtil;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
|
|
|
|
import com.gunshi.project.xyt.validate.markers.Update;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2024-07-10 14:04:43 +08:00
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
2024-07-08 17:47:02 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2024-07-10 14:04:43 +08:00
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.List;
|
2024-07-10 14:04:43 +08:00
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
/**
|
|
|
|
|
* 描述: 供水量表
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-07-08 17:40:37
|
|
|
|
|
*/
|
|
|
|
|
@Tag(name = "供水量表")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping(value="/stWaterR")
|
|
|
|
|
public class StWaterRController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StWaterRService service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
|
|
|
@PostMapping("/insert")
|
|
|
|
|
public R<StWaterR> insert(@Validated(Insert.class) @RequestBody StWaterR dto) {
|
|
|
|
|
boolean result = service.save(dto);
|
|
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改")
|
|
|
|
|
@PostMapping("/update")
|
|
|
|
|
public R<StWaterR> update(@Validated(Update.class) @RequestBody StWaterR dto) {
|
|
|
|
|
boolean result = service.updateById(dto);
|
|
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@GetMapping("/del/{id}")
|
|
|
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
|
|
|
|
return R.ok(service.removeById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "列表")
|
|
|
|
|
@PostMapping("/list")
|
2024-07-10 14:04:43 +08:00
|
|
|
public R<List<StWaterR>> list(@RequestBody @Validated StWaterR stWaterR) {
|
|
|
|
|
LambdaQueryWrapper<StWaterR> wrapper = new QueryWrapper<StWaterR>().lambda()
|
|
|
|
|
.eq(StringUtils.isNotBlank(stWaterR.getStcd()), StWaterR::getStcd, stWaterR.getStcd())
|
|
|
|
|
.ge(ObjectUtils.isNotNull(stWaterR.getStartTime()), StWaterR::getTm, stWaterR.getStartTime())
|
|
|
|
|
.le(ObjectUtils.isNotNull(stWaterR.getEndTime()), StWaterR::getTm, stWaterR.getEndTime())
|
2024-07-10 15:55:36 +08:00
|
|
|
.orderBy(StringUtils.isNotBlank(stWaterR.getSortField()), ObjectUtils.isEmpty(stWaterR.getIsAsc()) ? false : stWaterR.getIsAsc(), StWaterR::getTm);
|
2024-07-10 14:04:43 +08:00
|
|
|
return R.ok(service.list(wrapper));
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "分页")
|
|
|
|
|
@PostMapping("/page")
|
2024-07-10 14:04:43 +08:00
|
|
|
public R<Page<StWaterR>> page(@RequestBody @Validated StWaterR stWaterR) {
|
|
|
|
|
QueryWrapper<StWaterR> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq(StringUtils.isNotBlank(stWaterR.getStcd()), "stcd", stWaterR.getStcd())
|
|
|
|
|
.ge(ObjectUtils.isNotNull(stWaterR.getStartTime()), "tm", stWaterR.getStartTime())
|
|
|
|
|
.le(ObjectUtils.isNotNull(stWaterR.getEndTime()), "tm", stWaterR.getEndTime())
|
2024-07-10 15:55:36 +08:00
|
|
|
.orderBy(StringUtils.isNotBlank(stWaterR.getSortField()), ObjectUtils.isEmpty(stWaterR.getIsAsc()) ? false : stWaterR.getIsAsc(), "tm");
|
2024-07-10 14:04:43 +08:00
|
|
|
return R.ok(service.page(stWaterR.getPageSo().toPage(), qw));
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-10 14:04:43 +08:00
|
|
|
@Operation(summary = "导出")
|
|
|
|
|
@PostMapping("/exportWaterRDataExcel")
|
|
|
|
|
@CrossOrigin
|
|
|
|
|
public void exportWaterRDataExcel(@RequestBody @Validated StWaterR stWaterR, HttpServletResponse response) {
|
|
|
|
|
String filename = "供水流量表" + DateUtil.convertDateToString(stWaterR.getStartTime()) + "_" + DateUtil.convertDateToString(stWaterR.getEndTime());
|
|
|
|
|
List<StWaterRVo> vos = ConvertUtil.entityToVoList(this.list(stWaterR).getData(), StWaterRVo.class);
|
|
|
|
|
ExcelUtil.exportExcel(vos, filename, StWaterRVo.class, response, "供水流量表");
|
|
|
|
|
}
|
|
|
|
|
}
|