Source code

Download source archive ↓

src/CurrentAndPostValueInterpolation.scala

1package cn.piflow.bundle.flux.interpolationCalculation
2
3
4import cn.piflow.bundle.flux.util.FluxInterpolationUtil_4
5import cn.piflow.conf.bean.PropertyDescriptor
6import cn.piflow.conf.util.{ImageUtil, MapUtil}
7import cn.piflow.conf.{ConfigurableStop, Port}
8import cn.piflow.{JobContext, JobInputStream, JobOutputStream, ProcessContext}
9import org.apache.spark.sql.SparkSession
10
11class CurrentAndPostValueInterpolation extends ConfigurableStop{
12  val authorEmail: String = "ygang@cnic.cn"
13  val description: String = "TThe current value is invalid M(k), M (k+1) is invalid, M (k-1) is valid, and M (k+2) is valid.;Schema must contain hour, day_id fields (id incremented by date)"
14  val inportList: List[String] = List(Port.DefaultPort)
15  val outportList: List[String] = List(Port.DefaultPort)
16
17  var fields: String = _
18  var qualityControlMarkerValue: String = _
19
20
21  override def perform(in: JobInputStream, out: JobOutputStream, pec: JobContext): Unit = {
22    val spark = pec.get[SparkSession]()
23    val metroCBS = in.read()
24
25    val fluxInterpolation = new FluxInterpolationUtil_4
26
27    val interpolationResultDF = fluxInterpolation.CurrentAndPostValueInterpolation(spark,metroCBS,fields,qualityControlMarkerValue.toInt)
28
29
30    out.write(interpolationResultDF)
31  }
32
33  override def setProperties(map: Map[String, Any]): Unit = {
34    fields = MapUtil.get(map,"fields").asInstanceOf[String]
35    qualityControlMarkerValue = MapUtil.get(map,"qualityControlMarkerValue").asInstanceOf[String]
36
37  }
38
39  override def getPropertyDescriptor(): List[PropertyDescriptor] = {
40    var descriptor : List[PropertyDescriptor] = List()
41
42    val fields = new PropertyDescriptor()
43      .name("fields")
44      .displayName("fields")
45      .description("Fields that need to be interpolated, separated by commas")
46      .defaultValue("Ta_1_AVG,Pvapor_1_AVG,DR_5_CM11_AVG,PAR_7_AVG,Ts_107_1_AVG,Smoist_20cm_AVG,Ta_2_AVG,Ta_3_AVG,Pvapor_2_AVG,Pvapor_3_AVG,Ta_4_AVG,Ta_5_AVG,Pvapor_4_AVG,Pvapor_5_AVG,Ta_6_AVG,Ta_7_AVG,Pvapor_6_AVG,Pvapor_7_AVG")
47      .required(true)
48      .example("")
49    descriptor = fields :: descriptor
50
51    val qualityControlMarkerValue = new PropertyDescriptor()
52      .name("qualityControlMarkerValue")
53      .displayName("qualityControlMarkerValue")
54      .description("质量控制标记值:Quality control marker value")
55      .defaultValue("-9999")
56      .required(true)
57      .example("-9999")
58    descriptor = qualityControlMarkerValue :: descriptor
59
60
61    descriptor
62  }
63
64  override def getIcon(): Array[Byte] = {
65    ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
66  }
67
68  override def getGroup(): List[String] = {
69    List("Flux_interpolationCalculation")
70  }
71
72  override def initialize(ctx: ProcessContext): Unit = {
73
74  }
75
76}