|
@@ -2,9 +2,12 @@ package com.hb.proj.data.controller;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
+import org.apache.tomcat.util.buf.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
import com.hb.proj.base.service.WellParamService;
|
|
import com.hb.proj.base.service.WellParamService;
|
|
import com.hb.proj.constant.SortCodeConstant;
|
|
import com.hb.proj.constant.SortCodeConstant;
|
|
import com.hb.proj.data.service.ParamDataService;
|
|
import com.hb.proj.data.service.ParamDataService;
|
|
|
|
+import com.hb.proj.model.SingleDataVO;
|
|
import com.hb.proj.model.WellParamPO;
|
|
import com.hb.proj.model.WellParamPO;
|
|
import com.hb.proj.utils.RespVO;
|
|
import com.hb.proj.utils.RespVO;
|
|
import com.hb.proj.utils.RespVOBuilder;
|
|
import com.hb.proj.utils.RespVOBuilder;
|
|
@@ -74,19 +78,113 @@ public class WellDataController {
|
|
endDate=DateUtil.parse(nowstr+" 23:59:59");
|
|
endDate=DateUtil.parse(nowstr+" 23:59:59");
|
|
}
|
|
}
|
|
|
|
|
|
- String mainParamId=null;
|
|
|
|
- List<String> othParamId=new ArrayList<String>(params.size());
|
|
|
|
- for(WellParamPO wp : params) {
|
|
|
|
|
|
+
|
|
|
|
+ String mainParamId=wpservice.getParamId(wellId, SortCodeConstant.PARAM_FREQ);
|
|
|
|
+ PageModel<SingleDataVO> freqPaged=dataService.queryHisDataNoAlarm(mainParamId,startDate, endDate, pageNum, pageSize);
|
|
|
|
+ if(freqPaged==null || freqPaged.getData()==null || freqPaged.getData().size()==0) {
|
|
|
|
+ return RespVOBuilder.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ startDate=freqPaged.getData().get(freqPaged.getData().size()-1).getGatherTime();
|
|
|
|
+ endDate=freqPaged.getData().get(0).getGatherTime();
|
|
|
|
+
|
|
|
|
+ WellParamPO wp=null;
|
|
|
|
+ PageModel<SingleDataVO> othPaged=null;
|
|
|
|
+
|
|
|
|
+ Iterator<WellParamPO> paramIterator=params.iterator();
|
|
|
|
+ Map<String,WellParamPO> wpMapping=new HashMap<>(params.size());
|
|
|
|
+ while(paramIterator.hasNext()) {
|
|
|
|
+ wp=paramIterator.next();
|
|
|
|
+ if(wp.getParamCode().indexOf("diagram_")>=0) {
|
|
|
|
+ paramIterator.remove();
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
if(SortCodeConstant.PARAM_FREQ.equals(wp.getParamCode())) { //冲次为主
|
|
if(SortCodeConstant.PARAM_FREQ.equals(wp.getParamCode())) { //冲次为主
|
|
- mainParamId=wp.getParamId();
|
|
|
|
|
|
+ DataTransUtils.convert(wp, freqPaged.getData());
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- othParamId.add(wp.getParamId());
|
|
|
|
|
|
+ wpMapping.put(wp.getParamId(), wp);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- PageModel<Map<String,Object>> pagedData = dataService.queryMultiParamHisData(mainParamId, othParamId, startDate, endDate, pageNum, pageSize);
|
|
|
|
|
|
+ othPaged=dataService.queryHisDataNoAlarm(StringUtils.join(wpMapping.keySet()), startDate,endDate, 1, 10000);
|
|
|
|
+ Map<String,SingleDataVO> othDataMapping=buildMapping(othPaged.getData(),wpMapping);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //组装数据
|
|
|
|
+ List<Map<String,Object>> rsts=buildGridDatas(freqPaged.getData(),othDataMapping,params);
|
|
|
|
+ PageModel<Map<String,Object>> rtPaged=new PageModel<>();
|
|
|
|
+ rtPaged.setData(rsts);
|
|
|
|
+ rtPaged.setTotalRow(freqPaged.getTotalRow());
|
|
|
|
+ rtPaged.setCurrPage(freqPaged.getCurrPage());
|
|
|
|
+ rtPaged.setPageCount(freqPaged.getPageCount());
|
|
|
|
+
|
|
|
|
+ return RespVOBuilder.ok(rtPaged);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询优化方式2
|
|
|
|
+ */
|
|
|
|
+ private Map<String,SingleDataVO> buildMapping(List<SingleDataVO> datas,Map<String,WellParamPO> wpMapping){
|
|
|
|
+ Map<String,SingleDataVO> mapping=new HashMap<>(datas.size());
|
|
|
|
+ datas.forEach(data->{
|
|
|
|
+ DataTransUtils.convert(wpMapping.get(data.getWellParam()), data);
|
|
|
|
+ mapping.put(data.getWellParam()+"_"+data.getGatherTime().getTime(), data);
|
|
|
|
+ });
|
|
|
|
+ return mapping;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<Map<String,Object>> buildGridDatas(List<SingleDataVO> mainDatas,Map<String,SingleDataVO> othDatas,List<WellParamPO> params){
|
|
|
|
+ List<Map<String,Object>> rstDatas=new ArrayList<>(mainDatas.size());
|
|
|
|
+ Map<String,Object> itm=null;
|
|
|
|
+ SingleDataVO vo=null;
|
|
|
|
+ for(SingleDataVO mdata : mainDatas) {
|
|
|
|
+ itm=new HashMap<>(params.size()+1);
|
|
|
|
+ rstDatas.add(itm);
|
|
|
|
+ for(WellParamPO wp : params) {
|
|
|
|
+ if(SortCodeConstant.PARAM_FREQ.equals(wp.getParamCode())) {
|
|
|
|
+ itm.put("gatherTime", mdata.getGatherTime());
|
|
|
|
+ itm.put(wp.getParamCode(), mdata.getDispDataVal());
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ vo=othDatas.get(wp.getParamId()+"_"+mdata.getGatherTime().getTime());
|
|
|
|
+ itm.put(wp.getParamCode(), vo!=null?vo.getDispDataVal():null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rstDatas;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /** 查询优化方式1
|
|
|
|
+ private List<Map<String,Object>> buildGridDatas(List<SingleDataVO> mainDatas,Map<String,Map<Long,SingleDataVO>> othDataMapping,List<WellParamPO> params) {
|
|
|
|
+ List<Map<String,Object>> rstDatas=new ArrayList<>(mainDatas.size());
|
|
|
|
+ Map<String,Object> itm=null;
|
|
|
|
+ SingleDataVO vo=null;
|
|
|
|
+ for(SingleDataVO mdata : mainDatas) {
|
|
|
|
+ itm=new HashMap<>(params.size()+1);
|
|
|
|
+ rstDatas.add(itm);
|
|
|
|
+ for(WellParamPO wp : params) {
|
|
|
|
+ if(SortCodeConstant.PARAM_FREQ.equals(wp.getParamCode())) {
|
|
|
|
+ itm.put("gatherTime", mdata.getGatherTime());
|
|
|
|
+ itm.put(wp.getParamCode(), mdata.getDispDataVal());
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ vo=othDataMapping.get(wp.getParamCode()).get(mdata.getGatherTime().getTime());
|
|
|
|
+ itm.put(wp.getParamCode(), vo!=null?vo.getDispDataVal():null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- return RespVOBuilder.ok(pagedData);
|
|
|
|
|
|
+ return rstDatas;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private Map<Long,SingleDataVO> buildMapping(List<SingleDataVO> datas){
|
|
|
|
+ Map<Long,SingleDataVO> mapping=new HashMap<>(datas.size());
|
|
|
|
+ datas.forEach(data->{mapping.put(data.getGatherTime().getTime(), data);});
|
|
|
|
+ return mapping;
|
|
|
|
+ }*/
|
|
}
|
|
}
|