瀏覽代碼

增加功图特征提取接口、功图诊断接口

chenwen 1 年之前
父節點
當前提交
6970598981

+ 85 - 0
src/main/java/com/hb/proj/analysis/controller/DiagramDiagnoseController.java

@@ -1,5 +1,10 @@
 package com.hb.proj.analysis.controller;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -10,9 +15,17 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.hb.proj.allconfig.AccessToken;
 import com.hb.proj.allconfig.SysLog;
+import com.hb.proj.analysis.service.DiagramDetecter;
 import com.hb.proj.analysis.service.DiagramDiagnoseService;
+import com.hb.proj.base.service.WellParamService;
+import com.hb.proj.constant.SortCodeConstant;
+import com.hb.proj.data.controller.DataTransUtils;
+import com.hb.proj.data.service.DiagramDataService;
 import com.hb.proj.model.DiagramDiagnoseStandardPO;
 import com.hb.proj.model.DiagramDiagnoseStandardVO;
+import com.hb.proj.model.DiagramFeature;
+import com.hb.proj.model.MultiDataVO;
+import com.hb.proj.model.WellParamPO;
 import com.hb.proj.utils.RequestParams;
 import com.hb.proj.utils.RespVO;
 import com.hb.proj.utils.RespVOBuilder;
@@ -28,6 +41,12 @@ public class DiagramDiagnoseController {
 	@Autowired
 	private DiagramDiagnoseService  service;
 	
+	@Autowired
+	private WellParamService  wpService;
+	
+	@Autowired
+	private DiagramDataService  diagramService;
+	
 	@Value("${upload.access.path}")
 	private String accessPathPre;
 	
@@ -109,4 +128,70 @@ public class DiagramDiagnoseController {
 	  
 		
 	}
+	
+	/**
+	 * 更新井标准功图的特征值
+	 * @param feature
+	 * @param diagramTime
+	 * @param token
+	 * @return
+	 */
+	@RequestMapping("/updateDiagramFeature")
+	public RespVO<Object> updateDiagramFeature(@Validated DiagramFeature feature,Date diagramTime,AccessToken token){
+		
+		WellParamPO wparam=wpService.get(feature.getWellId(), SortCodeConstant.PARAM_DIAGRAM_LOAD);
+		MultiDataVO diagramGatherData=diagramService.get(wparam.getParamId(), diagramTime);
+		DataTransUtils.convert(wparam,diagramGatherData);
+		
+		DiagramDetecter.extractFeature(diagramGatherData, feature);
+		
+		feature.setModifyBy(token.getUsName());
+		if(StringUtils.isNotBlank(feature.getFeatureId())) {
+			service.updateDiagramFeature(feature);
+		}
+		else {
+			service.addDiagramFeature(feature);
+		}
+		return RespVOBuilder.ok();
+	}
+	
+	/**
+	 * 获得指定井标准功图特征值
+	 * @param wellId
+	 * @return
+	 */
+	@RequestMapping("/getDiagramFeature")
+	public RespVO<DiagramFeature> getDiagramFeature(String wellId){
+		return RespVOBuilder.ok(service.getDiagramFeatureByWell(wellId));
+	}
+	
+	/**
+	 * 诊断外部传入功图数据
+	 * @param wellId
+	 * @param diagramTime
+	 * @param serials
+	 * @return
+	 */
+	@RequestMapping("/diagnoseOut")
+	public RespVO<Object> diagnoseOut(String wellId,Date diagramTime,String disps,String oths){
+		
+		WellParamPO wparam=wpService.get(wellId, SortCodeConstant.PARAM_DIAGRAM_LOAD);
+		MultiDataVO diagramData=diagramService.get(wparam.getParamId(), diagramTime);
+		
+		diagramData.setDisps(convert(disps));
+		diagramData.setOths(convert(oths));
+		
+		DiagramFeature feature=service.getDiagramFeatureByWell(wellId);
+		return RespVOBuilder.ok(DiagramDetecter.detect(diagramData, feature));
+	}
+	
+	private List<Double>  convert(String serial){
+		String[] datas=serial.split(",");
+		List<Double> rst=new ArrayList<>(datas.length);
+		for(String d : datas) {
+			rst.add(Double.parseDouble(d));
+		}
+		return rst;
+	}
+	
 }

+ 20 - 0
src/main/java/com/hb/proj/analysis/service/DiagramDiagnoseService.java

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
 
 import com.hb.proj.model.DiagramDiagnoseStandardPO;
 import com.hb.proj.model.DiagramDiagnoseStandardVO;
+import com.hb.proj.model.DiagramFeature;
 import com.hb.xframework.dao.core.SpringJdbcDAO;
 import com.hb.xframework.dao.util.PageModel;
 import com.hb.xframework.dao.util.UUIDHexGenerator;
@@ -81,4 +82,23 @@ public class DiagramDiagnoseService {
 		return dao.update(diagnosePO, "tzl_diagram_diagnose_standard", "diagnose_id")>0;
 	}
 	
+	
+	
+	public String addDiagramFeature(DiagramFeature feature) {
+		UUIDHexGenerator uuid=UUIDHexGenerator.getInstance();
+		feature.setFeatureId(uuid.generate());
+		feature.setModifyTime(new Date());
+		dao.insert(feature,"tzl_diagram_feature");
+		return feature.getFeatureId();
+	}
+	
+	public boolean updateDiagramFeature(DiagramFeature feature) {
+		feature.setModifyTime(new Date());
+		return dao.update(feature, "tzl_diagram_feature", "feature_id")>0;
+	}
+	
+	public DiagramFeature getDiagramFeatureByWell(String wellId) {
+		return dao.queryForPojo("select * from tzl_diagram_feature where well_id=?", DiagramFeature.class, wellId);
+	}
+	
 }

+ 2 - 2
src/main/java/com/hb/proj/data/controller/DataTransUtils.java

@@ -95,8 +95,8 @@ public class DataTransUtils {
 		if(gdata==null||StringUtils.isBlank(gdata.getDataVal1())||StringUtils.isBlank(gdata.getDataVal2())) {
 			return;
 		}
-		gdata.setSerial1(convertForDiagram(gdata.getDataVal1(),wp.getDisplayFormat2(),wp.getDisInsScale2()));
-		gdata.setSerial2(convertForDiagram(gdata.getDataVal2(),wp.getDisplayFormat(),wp.getDisInsScale()));
+		gdata.setDisps(convertForDiagram(gdata.getDataVal1(),wp.getDisplayFormat2(),wp.getDisInsScale2()));
+		gdata.setOths(convertForDiagram(gdata.getDataVal2(),wp.getDisplayFormat(),wp.getDisInsScale()));
 		
 	}
 	

+ 3 - 3
src/main/java/com/hb/proj/data/controller/DiagramDataController.java

@@ -130,8 +130,8 @@ public class DiagramDataController {
 		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());
+		serial.put("xvals", diagram.getDisps());
+		serial.put("yvals", diagram.getOths());
 		serial.put("smpTime", smpTime);
 		
 		return MapUtils.build("base",base,"serial",serial,"descTxt",descTxt);
@@ -193,7 +193,7 @@ public class DiagramDataController {
 		}
 		List<Map<String,Object>>  serials=new ArrayList<Map<String,Object>>(diagrams.size());
 		for(MultiDataVO  diagram : diagrams) {
-			serials.add(MapUtils.build("xvals",diagram.getSerial1(),"yvals", diagram.getSerial2(),"smpTime",diagram.getGatherTime()));
+			serials.add(MapUtils.build("xvals",diagram.getDisps(),"yvals", diagram.getOths(),"smpTime",diagram.getGatherTime()));
 		}
 		return MapUtils.build("base",base,"serial",serials);
 	}

+ 1 - 1
src/main/java/com/hb/proj/data/service/DiagramDataService.java

@@ -43,7 +43,7 @@ public class DiagramDataService {
 	
 	public MultiDataVO   get(String paramId,Date gatherTime) {
 		String sql="""
-					select well_param,gather_time,data_val1,data_val2,freq 
+					select well_param,gather_time,data_val1,data_val2,freq,stroke,glb_max,glb_min,turn_index 
 					from tzl_gather_data_multi 
 					where well_param=?  and gather_time=?  
 					limit 1

+ 29 - 2
src/main/java/com/hb/proj/model/MultiDataVO.java

@@ -16,13 +16,40 @@ public class MultiDataVO {
 	
 	private String dataVal2;
 	
-	private List<Double> serial1;
+	/**
+	 * 位移序列
+	 */
+	private List<Double> disps;
 	
-	private List<Double> serial2;
+	/**
+	 * 其它参数(载荷、电流、功率)
+	 */
+	private List<Double> oths;
 	
 	/**
 	 * 冲次
 	 */
 	private Double freq;
 	
+	/**
+	 * 冲程
+	 */
+	private Double stroke;
+	
+	/**
+	 * 最大采集值
+	 */
+	private Double glbMax;
+	
+	/**
+	 * 最小采集值
+	 */
+	private Double glbMin;
+	
+	
+	/**
+	 * 上下行切换位置
+	 */
+	private Integer turnIndex;
+	
 }

+ 0 - 23
src/main/java/com/hb/proj/model/WellRtDataVO.java

@@ -1,23 +0,0 @@
-package com.hb.proj.model;
-
-import lombok.Data;
-
-/**
- * 单井实时数据
- * @author cwen
- *
- */
-
-@Data
-public class WellRtDataVO {
-
-	/**
-	 * 冲次   spm  次/min
-	 */
-	private Double freq;
-	
-	/**
-	 * 套压
-	 */
-	private Double casingPress;
-}