1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package com.hb.proj.data.controller;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import com.hb.proj.base.service.WellParamService;
- import com.hb.proj.constant.SortCodeConstant;
- import com.hb.proj.data.service.ParamDataService;
- import com.hb.proj.model.WellParamPO;
- import com.hb.proj.utils.RespVO;
- import com.hb.proj.utils.RespVOBuilder;
- import com.hb.xframework.dao.util.PageModel;
- import com.hb.xframework.util.DateUtil;
- import jakarta.validation.constraints.NotBlank;
- @RestController
- @RequestMapping("/welldata")
- @Validated
- public class WellDataController {
- @Autowired
- private WellParamService wpservice;
-
- @Autowired
- private ParamDataService dataService;
-
-
- /**
- * 加载单井历史数据表头
- * @param wellId
- * @return
- */
- @RequestMapping("/loadHisDataHeader")
- public RespVO<List<WellParamPO>> loadHisDataHeader(@NotBlank(message="缺少井号参数") String wellId){
- return RespVOBuilder.ok(wpservice.loadParamByWell(wellId));
- }
-
- /**
- * 单井历史数据查询
- * @param wellId
- * @param startDate
- * @param endDate
- * @param pageNum
- * @param pageSize
- * @return
- */
- @RequestMapping("/queryHisData")
- public RespVO<PageModel<Map<String,Object>>> queryHisData(
- @NotBlank(message="缺少井号参数") String wellId,
- Date startDate,
- Date endDate,
- @RequestParam(value = "currentPage", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize){
-
- List<WellParamPO> params=wpservice.loadParamByWell(wellId);
- if(params==null||params.size()==0) {
- return RespVOBuilder.error("该井未定义参数");
- }
-
- String nowstr=DateUtil.format(new Date(), "yyyy-MM-dd");
- if(startDate==null) {
- startDate=DateUtil.parse(nowstr+" 00:00:00");
- }
- if(endDate==null) {
- endDate=DateUtil.parse(nowstr+" 23:59:59");
- }
-
- String mainParamId=null;
- List<String> othParamId=new ArrayList<String>(params.size());
- for(WellParamPO wp : params) {
- if(SortCodeConstant.PARAM_FREQ.equals(wp.getParamCode())) { //冲次为主
- mainParamId=wp.getParamId();
- }
- else {
- othParamId.add(wp.getParamId());
- }
- }
-
- PageModel<Map<String,Object>> pagedData = dataService.queryMultiParamHisData(mainParamId, othParamId, startDate, endDate, pageNum, pageSize);
-
- return RespVOBuilder.ok(pagedData);
- }
- }
|