From cdf5e280513558ec900bc18c1e2fb53deabbf6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A?= Date: Thu, 31 Oct 2024 11:34:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E6=85=A7=E6=A0=A1=E5=9B=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile => shapelight-admin/Dockerfile | 4 +- shapelight-admin/pom.xml | 71 ++++++++++++++++++- .../java/net/shapelight/AdminApplication.java | 4 +- .../modules/job/task/EmpowerTask.java | 42 +++++++++++ .../ten/controller/TenParentController.java | 2 +- .../src/main/resources/application.yml | 4 +- 6 files changed, 118 insertions(+), 9 deletions(-) rename Dockerfile => shapelight-admin/Dockerfile (80%) create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/job/task/EmpowerTask.java diff --git a/Dockerfile b/shapelight-admin/Dockerfile similarity index 80% rename from Dockerfile rename to shapelight-admin/Dockerfile index d11d051..0786a7c 100644 --- a/Dockerfile +++ b/shapelight-admin/Dockerfile @@ -1,5 +1,5 @@ # 使用官方Java运行环境作为基础镜像 -FROM openjdk:1.8-jre-slim +FROM openjdk:8 # 指定维护者信息 LABEL maintainer="zhangbo" @@ -8,7 +8,7 @@ LABEL maintainer="zhangbo" VOLUME /tmp # 将jar包添加到容器中并更名为app.jar -ADD shapelight-admin/target/shapelight-admin.jar app.jar +ADD target/shapelight-admin.jar app.jar # 暴露容器内的端口给外部访问 EXPOSE 8018 diff --git a/shapelight-admin/pom.xml b/shapelight-admin/pom.xml index 27390a4..f48540b 100644 --- a/shapelight-admin/pom.xml +++ b/shapelight-admin/pom.xml @@ -244,12 +244,38 @@ + org.springframework.boot + spring-boot-maven-plugin + + + + com.spotify + docker-maven-plugin + 1.2.2 + + + shapelight/admin + java:8-alpine + ["java", "-jar", "/${project.build.finalName}.jar"] + + + / + ${project.build.directory} + ${project.build.finalName}.jar + + + + http://192.168.10.62:2375 + + + - + <!– 运行命令 mvn clean package docker:build 打包并生成docker镜像 –> + --> + + diff --git a/shapelight-admin/src/main/java/net/shapelight/AdminApplication.java b/shapelight-admin/src/main/java/net/shapelight/AdminApplication.java index c88c85f..4754793 100644 --- a/shapelight-admin/src/main/java/net/shapelight/AdminApplication.java +++ b/shapelight-admin/src/main/java/net/shapelight/AdminApplication.java @@ -29,8 +29,8 @@ public class AdminApplication { SpringApplication.run(AdminApplication.class, args); //初始化掌静脉sdk - //int initCode = PalmSDK.init(); - //log.debug("掌静脉sdk初始化。。。。。。。。。。:"+initCode); + int initCode = PalmSDK.init(); + log.debug("掌静脉sdk初始化。。。。。。。。。。:"+initCode); // //mqtt服务启动 // MqttClientUtil.createClient(); // diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/EmpowerTask.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/EmpowerTask.java new file mode 100644 index 0000000..b02d96e --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/EmpowerTask.java @@ -0,0 +1,42 @@ +package net.shapelight.modules.job.task; + +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import net.shapelight.modules.job.entity.KeysEntity; +import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +@Component("empowerTask") +@Slf4j +public class EmpowerTask implements ITask{ + @Autowired + private OpFeignClient feignClient; + + @Value("${global.qingju.accountNumber}") + String accountNumber; + @Value("${global.qingju.empowerKey}") + String empowerKey; + + // 定义Token续期的方法 + public void renewToken() { + Map params = new HashMap<>(); + params.put("accountNumber",accountNumber); + params.put("empowerKey", empowerKey); + JSONObject json = feignClient.empower(params); + if(json.getString("shrgStatus").equals("S")) { + KeysEntity.passKey = json.getString("passKey"); + KeysEntity.empowerText = json.getString("empowerText"); + log.debug("TokenResponse:{}", json.getString("passKey")); + } + } + + @Override + public void run(String params) { + renewToken(); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java index 59f7a9d..4df107e 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java @@ -104,7 +104,7 @@ public class TenParentController { TenParent tenParent = tenParentService.getById(id); AppUserEntity userEntity = appUserService.getById(tenParent.getUserId()); userEntity.setPassword(DigestUtils.sha256Hex(passWord)); - appUserService.save(userEntity); + appUserService.updateById(userEntity); return R.ok(); } } diff --git a/shapelight-admin/src/main/resources/application.yml b/shapelight-admin/src/main/resources/application.yml index 8621a87..ca7f46a 100644 --- a/shapelight-admin/src/main/resources/application.yml +++ b/shapelight-admin/src/main/resources/application.yml @@ -64,14 +64,14 @@ spring: async: request-timeout: 60000 #60秒 resources: - static-locations: file:/home/huangyifang/project/cell #根目录 + static-locations: file:D:/project/cell/temp #根目录 #file: #文件上传目录(注意Linux和Windows上的目录结构不同) #uploadPath: D:/project/cell/temp global: http_flag: http file_path: - static-locations: /home/huangyifang/project/cell #根目录,必须是在static-locations下 + static-locations: D:/project/cell/temp #根目录,必须是在static-locations下 temp_dir: temp images_dir: images apk_dir: apk