|
@@ -0,0 +1,110 @@
|
|
|
+package com.hb.proj.data.controller;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+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.RestController;
|
|
|
+
|
|
|
+import com.hb.proj.base.service.WellParamService;
|
|
|
+import com.hb.proj.base.service.WellService;
|
|
|
+import com.hb.proj.constant.SortCodeConstant;
|
|
|
+import com.hb.proj.data.service.DiagramDataService;
|
|
|
+import com.hb.proj.data.service.ParamDataService;
|
|
|
+import com.hb.proj.model.GatherDataPO;
|
|
|
+import com.hb.proj.model.MultiGatherPO;
|
|
|
+import com.hb.proj.model.WellParamPO;
|
|
|
+import com.hb.proj.model.WellVO;
|
|
|
+import com.hb.proj.utils.RespVO;
|
|
|
+import com.hb.proj.utils.RespVOBuilder;
|
|
|
+import com.hb.xframework.util.DateUtil;
|
|
|
+import com.hb.xframework.util.MapUtils;
|
|
|
+
|
|
|
+import jakarta.validation.constraints.NotBlank;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/diagram")
|
|
|
+@Validated
|
|
|
+public class DiagramDataController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WellService wellService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WellParamService wpService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DiagramDataService diagramService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ParamDataService paramDataService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得功图绘制数据
|
|
|
+ * @param wellId
|
|
|
+ * @param paramCode
|
|
|
+ * @param action
|
|
|
+ * @param refTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/getDrawData")
|
|
|
+ public RespVO<Object> getDrawData(@NotBlank(message = "缺少井记录号") String wellId,
|
|
|
+ @NotBlank(message = "缺少采集参数编码") String paramCode,String action ,Date refTime){
|
|
|
+
|
|
|
+ WellParamPO wparam=wpService.get(wellId, paramCode);
|
|
|
+ MultiGatherPO diagram=diagramService.get(wparam.getParamId(), refTime, action);
|
|
|
+ if(diagram==null) {
|
|
|
+ return RespVOBuilder.error("无数据");
|
|
|
+ }
|
|
|
+ GatherDataUtils.convert(wparam,diagram);
|
|
|
+
|
|
|
+ WellVO well=wellService.get(wellId);
|
|
|
+ WellParamPO freqParam=wpService.get(wellId, SortCodeConstant.PARAM_FREQ);
|
|
|
+ GatherDataPO freqPO=paramDataService.getRefFreq(freqParam.getParamId(), diagram.getGatherTime());
|
|
|
+ GatherDataUtils.convert(freqParam, freqPO);
|
|
|
+ String freqDesc=freqPO!=null?(freqPO.getDispDataVal()+freqParam.getDisplayUnit()):"";
|
|
|
+
|
|
|
+ return RespVOBuilder.ok(buildData(well,wparam,diagram,freqDesc));
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String,Object> buildData(WellVO well,WellParamPO wparam,MultiGatherPO diagram,String freq){
|
|
|
+ String smpTime=DateUtil.format(diagram.getGatherTime(),"yyyy-MM-dd HH:mm:ss");
|
|
|
+ String[] dtstr=smpTime.split(" ");
|
|
|
+ Map<String,Object> base=new HashMap<String,Object>();
|
|
|
+ base.put("xTitle", wparam.getSerialName2()+"("+wparam.getDisplayUnit2()+")");
|
|
|
+ base.put("yTitle", wparam.getSerialName()+"("+wparam.getDisplayUnit()+")");
|
|
|
+ base.put("xUnit", wparam.getDisplayUnit2());
|
|
|
+ base.put("yUnit", wparam.getDisplayUnit());
|
|
|
+ base.put("title", "时间: "+dtstr[1]);
|
|
|
+ base.put("type", SortCodeConstant.paramType.get(wparam.getParamCode()));
|
|
|
+
|
|
|
+ String[] descTxt= {"隶属单位:"+well.getBelongOrgName(),"井名:"+well.getWellName(),"测试日期:"+dtstr[0],"冲次:"+freq};
|
|
|
+
|
|
|
+ Map<String,Object> serial=new HashMap<String,Object>();
|
|
|
+ serial.put("xvals", diagram.getSerial1());
|
|
|
+ serial.put("yvals", diagram.getSerial2());
|
|
|
+
|
|
|
+ return MapUtils.build("base",base,"serial",serial,"descTxt",descTxt);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ private Map<String,Object> buildData(){
|
|
|
+ String nowstr=DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss");
|
|
|
+ Map<String,Object> base=MapUtils.build("xTitle","位移(m)","yTitle","负荷(kN)","xUnit","m","yUnit","kN","title","CQ-2 2019-09-09","type","GT");
|
|
|
+ Map<String,Object> serial=MapUtils.build("smpTime",nowstr);
|
|
|
+ double[] x= {0.2,1.0,2.0,3.0,4.0,5.0,3.0,2.0,1.0};
|
|
|
+ double[] y= {15.4,28,34,44,50,18,38,66,32};
|
|
|
+ serial.put("xvals", x);
|
|
|
+ serial.put("yvals", y);
|
|
|
+
|
|
|
+ String[] dtstr=nowstr.split(" ");
|
|
|
+ String[] descTxt= {"时间: "+dtstr[1],"隶属单位:特油组","井名:杜84","测试日期:"+dtstr[0],"冲次:"};
|
|
|
+
|
|
|
+ return MapUtils.build("base",base,"serial",serial,"descTxt",descTxt);
|
|
|
+ }*/
|
|
|
+}
|