Browse Source

dmp-file增加DockerFile文件

linhuili 3 years ago
parent
commit
70f6f704c7

+ 1 - 1
dmp-business/dmp-dic/src/main/resources/bootstrap.yml

@@ -1,5 +1,5 @@
 server:
-  port: 9001
+  port: 8831
 spring:
   application:
     # 应用名称

+ 1 - 1
dmp-business/dmp-rwd-version/src/main/resources/bootstrap.yml

@@ -1,5 +1,5 @@
 server:
-  port: 9001
+  port: 8833
 spring:
   application:
     # 应用名称

+ 37 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/controller/IotController.java

@@ -0,0 +1,37 @@
+package com.persagy.dmp.rwd.iot.controller;
+
+
+import com.persagy.dmp.common.constant.CommonConstant;
+import com.persagy.dmp.common.model.response.CommonResult;
+import com.persagy.dmp.common.utils.ParamCheckUtil;
+import com.persagy.dmp.common.utils.ResultHelper;
+import com.persagy.dmp.rwd.iot.model.CurrentDataModel;
+import com.persagy.dmp.rwd.iot.service.CurrentDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * iot-查询实时数据
+ * @author:linhuili
+ * @date:2021/8/11
+ */
+@RestController
+@RequestMapping("/rwd/iot")
+public class IotController {
+
+	@Autowired
+	private CurrentDataService currentDataService;
+
+	@PostMapping("/data/current")
+	public CommonResult<List<CurrentDataModel>> current(@RequestBody List<CurrentDataModel> param) {
+		//基础参数校验
+		ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
+		List<CurrentDataModel> currentData = currentDataService.getCurrentData(param);
+		return ResultHelper.multi(currentData,currentData.size());
+	}
+}

+ 57 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/model/CurrentDataModel.java

@@ -0,0 +1,57 @@
+package com.persagy.dmp.rwd.iot.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class CurrentDataModel {
+
+	private String objectId;
+	private String infoCode;
+	private String infoValue;
+	private String time;
+	private Object data;
+	private String error;
+
+	@JsonIgnore
+	private String[] infoValueArr;
+
+
+	public CurrentDataModel() {
+	}
+
+	public CurrentDataModel(String objectId, String infoCode) {
+		this.objectId = objectId;
+		this.infoCode = infoCode;
+	}
+
+	public String getMeter() {
+		if (this.infoValue == null) {
+			return null;
+		}
+		if (this.infoValueArr == null) {
+			this.infoValueArr = this.infoValue.split("-");
+		}
+		if (this.infoValueArr.length == 0) {
+			return null;
+		} else {
+			return this.infoValueArr[0];
+		}
+	}
+
+	public String getFunction() {
+		if (this.infoValue == null) {
+			return null;
+		}
+		if (this.infoValueArr == null) {
+			this.infoValueArr = this.infoValue.split("-");
+		}
+		if (this.infoValueArr.length < 2) {
+			return null;
+		} else {
+			return this.infoValueArr[1];
+		}
+	}
+}

+ 15 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/model/DataInfo.java

@@ -0,0 +1,15 @@
+package com.persagy.dmp.rwd.iot.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class DataInfo {
+
+	private String objectId;
+	private String classCode;
+	private String infoCode;
+	private String infoCodeValue;
+
+}

+ 20 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/model/SettingDataModel.java

@@ -0,0 +1,20 @@
+package com.persagy.dmp.rwd.iot.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class SettingDataModel {
+
+	private String objectId;
+	private String infoCode;
+	private Double value;
+	private String status;
+	private String error;
+	private String meter;
+	private String function;
+	private String exeCode;
+	private String exeResult;
+	private String receivetime;
+}

+ 20 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/model/history/DataModel.java

@@ -0,0 +1,20 @@
+package com.persagy.dmp.rwd.iot.model.history;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class DataModel {
+
+	private String time;
+	private Object data;
+
+	public DataModel() {
+	}
+
+	public DataModel(String time, Object data) {
+		this.time = time;
+		this.data = data;
+	}
+}

+ 19 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/model/history/InfoCodeModel.java

@@ -0,0 +1,19 @@
+package com.persagy.dmp.rwd.iot.model.history;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class InfoCodeModel {
+
+	private String objectId;
+	private String infoCode;
+	private String meter;
+	private String function;
+	private String status;
+	private String error;
+
+	private ArrayNode data;
+}

+ 18 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/model/history/RequestModel.java

@@ -0,0 +1,18 @@
+package com.persagy.dmp.rwd.iot.model.history;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class RequestModel {
+
+	private String startTime;
+	private String endTime;
+	private String period;
+
+	private List<InfoCodeModel> params;
+
+}

+ 16 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/service/CurrentDataService.java

@@ -0,0 +1,16 @@
+package com.persagy.dmp.rwd.iot.service;
+
+import com.persagy.dmp.common.model.response.CommonResult;
+import com.persagy.dmp.rwd.iot.model.CurrentDataModel;
+
+import java.util.List;
+
+public interface CurrentDataService {
+
+    /**
+     * 查询实时数据
+     * @param param
+     * @return
+     */
+    List<CurrentDataModel> getCurrentData(List<CurrentDataModel> param);
+}

+ 68 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/iot/service/impl/CurrentDataServiceImpl.java

@@ -0,0 +1,68 @@
+package com.persagy.dmp.rwd.iot.service.impl;
+
+import com.persagy.dmp.common.context.AppContext;
+import com.persagy.dmp.rwd.iot.model.CurrentDataModel;
+import com.persagy.dmp.rwd.iot.service.CurrentDataService;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * iot-查询实时数据
+ * @author:linhuili
+ * @date:2021/8/11
+ */
+@Service
+public class CurrentDataServiceImpl implements CurrentDataService {
+
+    /**
+     * 查询实时数据
+     * @param param
+     * @return
+     */
+    @Override
+    public List<CurrentDataModel> getCurrentData(List<CurrentDataModel> param) {
+        if(param == null || param.size()<=0){
+            return new ArrayList<>();
+        }
+
+        String groupCode = AppContext.getContext().getGroupCode();
+        String projectId = AppContext.getContext().getProjectId();
+
+        //查询对象绑点信息点的实时数据
+        List<PointParam> parameters = new LinkedList<>();
+        for (CurrentDataModel model : param) {
+            if (model.getObjectId() == null) {
+                model.setError("对象id不可为空");
+                continue;
+            }
+            String infoCode = model.getInfoCode();
+            if (infoCode == null) {
+                model.setError("信息点编码不可为空");
+                continue;
+            }
+
+            //表号功能号校验
+           // String infoCodeValue = getInfoCodeValue(groupCode, projectId, model.getObjectId(), infoCode);
+            parameters.add(new PointParam(model.getMeter(), model.getFunction()));
+        }
+        return null;
+    }
+
+    /**
+     * 信息点参数定义
+     */
+    @Getter
+    @Setter
+    public static class PointParam {
+        String meter;
+        String funcid;
+
+        public PointParam(String meter, String function) {
+            this.meter = meter;
+            this.funcid = function;
+        }
+    }
+}

+ 1 - 1
dmp-business/dmp-rwd/src/main/resources/bootstrap.yml

@@ -3,7 +3,7 @@ server:
 spring:
   application:
     # 应用名称
-    name: dc-digital
+    name: dmp-rwd
 
 config:
   file:

+ 36 - 0
docker/dockerfiles/dmp-file/Dockerfile

@@ -0,0 +1,36 @@
+#构建此镜像的基础镜像
+FROM java:8-jre
+#指定作者名称
+MAINTAINER lijie<lijie@persagy.com>
+
+#定义标签属性
+LABEL tier=backend
+LABEL product=dmp
+LABEL project=dmp-file
+LABEL name=bdtp-dic
+
+#设置环境变量
+ENV JAVA_OPTS -Dfile.encoding=UTF-8 -Xms2048m -Xmx2048m
+ENV TZ Asia/Shanghai
+#ARG 可以接收docker build命令中以--build-arg 指定的参数
+ARG WORKER_HOME
+
+#执行的命令
+RUN apt-get install -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime	&& echo 'Asia/Shanghai' > /etc/timezone
+
+RUN mkdir -p $WORKER_HOME/config
+
+#复制文件到容器内
+COPY *.jar $WORKER_HOME/app.jar
+COPY entrypoint.sh $WORKER_HOME/
+COPY version.txt $WORKER_HOME/
+COPY config/* $WORKER_HOME/config/
+#设置工作目录
+WORKDIR $WORKER_HOME
+
+#查看上述复制的文件,是否复制成功
+RUN ls
+
+#启动执行
+ENTRYPOINT ["sh","./entrypoint.sh"]

+ 3 - 0
docker/dockerfiles/dmp-file/entrypoint.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "entrypoint run..."
+java -jar $JAVA_OPTS -Deureka.client.service-url.defaultZone=$EUREKA_CLIENT_DEFAULT_ZONE -Dspring.cloud.config.profile=$SPRING_CLOUD_CONFIG_PROFILE -Dspring.cloud.config.uri=$SPRING_CLOUD_CONFIG_URI app.jar

+ 70 - 0
docker/k8sfiles/dmp-file.yml

@@ -0,0 +1,70 @@
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: dmp-file
+  labels:
+    app: dmp-file
+spec:
+  selector:
+    app: dmp-file
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: dmp-file
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: dmp-file
+  template:
+    metadata:
+      labels:
+        app: dmp-file
+    spec:
+      containers:
+      - name: dmp-file
+        image: labisenlin.persagy.com/library/dmp-file:v2.0.0
+        imagePullPolicy: Always
+        env:
+        - name: TZ
+          value: Asia/Shanghai
+        - name: SERVER_PORT
+          value: "8114"
+        - name: SPRING_CLOUD_CONFIG_URI
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: spring.cloud.config.uri
+        - name: SPRING_PROFILES_ACTIVE
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: spring.profiles.active
+        - name: SPRING_CLOUD_CONFIG_PROFILE
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: spring.cloud.config.profile
+        - name: EUREKA_CLIENT_FETCH_REGISTRY
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: eureka.client.fetch-registry
+        - name: EUREKA_CLIENT_REGISTER_WITH_EUREKA
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: eureka.client.register-with-eureka
+        - name: EUREKA_CLIENT_DEFAULT_ZONE
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: eureka.client.default.zone
+        - name: EUREKA_INSTANCE_IP_ADDRESS
+          valueFrom:
+            configMapKeyRef:
+              name: dmp-file
+              key: eureka.instance.ip.address