LiquidController.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.hb.proj.data.controller;
  2. import java.util.Date;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.validation.annotation.Validated;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestParam;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.hb.proj.data.service.LiquidService;
  9. import com.hb.proj.model.LiquidPO;
  10. import com.hb.proj.model.LiquidVO;
  11. import com.hb.proj.utils.RespVO;
  12. import com.hb.proj.utils.RespVOBuilder;
  13. import com.hb.xframework.dao.util.PageModel;
  14. import com.hb.xframework.util.DateUtil;
  15. import jakarta.validation.constraints.NotBlank;
  16. @RestController
  17. @RequestMapping("/liquid")
  18. @Validated
  19. public class LiquidController {
  20. @Autowired
  21. private LiquidService service;
  22. /**
  23. * 分页查询指定井的动液面数据
  24. * @param wellId
  25. * @param startTime
  26. * @param endTime
  27. * @param pageNum
  28. * @param pageSize
  29. * @return
  30. */
  31. @RequestMapping("/query")
  32. public RespVO<PageModel<LiquidVO>> query(@NotBlank(message="井号不能为空") String wellId,
  33. Date startTime,Date endTime,
  34. @RequestParam(value = "currentPage", defaultValue = "1") Integer pageNum,
  35. @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
  36. String nowstr=DateUtil.format(new Date(), "yyyy-MM-dd");
  37. if(startTime==null) {
  38. startTime=DateUtil.parse(nowstr+" 00:00:00");
  39. }
  40. if(endTime==null) {
  41. endTime=DateUtil.parse(nowstr+" 23:59:59");
  42. }
  43. return RespVOBuilder.ok(service.query(wellId, startTime,endTime,pageNum, pageSize));
  44. }
  45. /**
  46. * 获得动液面单个记录明细数据
  47. * @param dataId
  48. * @return
  49. */
  50. @RequestMapping("/get")
  51. public RespVO<LiquidPO> get(@NotBlank(message="记录号不能为空") String dataId){
  52. return RespVOBuilder.ok(service.getDtl(dataId));
  53. }
  54. /**
  55. * 保存计算结果
  56. * @param liquid
  57. * @return
  58. */
  59. @RequestMapping("/save")
  60. public RespVO<Object> save(@Validated LiquidPO liquid){
  61. service.saveCalculate(liquid);
  62. return RespVOBuilder.ok();
  63. }
  64. /**
  65. * 逻辑删除单个记录
  66. * @param liquid
  67. * @return
  68. */
  69. @RequestMapping("/delete")
  70. public RespVO<Object> delete(@NotBlank(message="记录号不能为空") String dataId){
  71. service.delete(dataId);
  72. return RespVOBuilder.ok();
  73. }
  74. }