Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition
# Conflicts: # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/TestApi.java
This commit is contained in:
commit
d5394ee6d3
|
|
@ -9,10 +9,13 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.MaterialMainVO;
|
import com.nflg.product.bomnew.pojo.vo.MaterialMainVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.SystemInfoVO;
|
||||||
import com.nflg.product.bomnew.service.SapOpUtilService;
|
import com.nflg.product.bomnew.service.SapOpUtilService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
@ -21,9 +24,18 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.nio.file.attribute.FileTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹鹏飞
|
* @author 曹鹏飞
|
||||||
|
|
@ -31,6 +43,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Api(tags = "测试功能用的接口")
|
@Api(tags = "测试功能用的接口")
|
||||||
@RestController
|
@RestController
|
||||||
|
@Slf4j
|
||||||
@RequestMapping("test")
|
@RequestMapping("test")
|
||||||
public class TestApi {
|
public class TestApi {
|
||||||
|
|
||||||
|
|
@ -40,6 +53,11 @@ public class TestApi {
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialMainClient materialMainClient;
|
private MaterialMainClient materialMainClient;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
private static SystemInfoVO SYSTEM_INFO_VO;
|
||||||
|
|
||||||
@GetMapping("materialUpdateBill")
|
@GetMapping("materialUpdateBill")
|
||||||
@ApiOperation("物料变更申请单测试")
|
@ApiOperation("物料变更申请单测试")
|
||||||
public ResultVO testMaterialUpdateBill() {
|
public ResultVO testMaterialUpdateBill() {
|
||||||
|
|
@ -102,4 +120,53 @@ public class TestApi {
|
||||||
}
|
}
|
||||||
return ResultVO.success(msgs);
|
return ResultVO.success(msgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("getSystemInfo")
|
||||||
|
@ApiOperation("获取系统信息")
|
||||||
|
public ResultVO<SystemInfoVO> getSystemInfo() {
|
||||||
|
if (Objects.isNull(SYSTEM_INFO_VO)) {
|
||||||
|
log.debug("spring.profiles.active:" + environment.getProperty("spring.profiles.active"));
|
||||||
|
switch (environment.getProperty("spring.profiles.active")) {
|
||||||
|
case "dev":
|
||||||
|
SYSTEM_INFO_VO = new SystemInfoVO();
|
||||||
|
SYSTEM_INFO_VO.setActive("开 发 机");
|
||||||
|
SYSTEM_INFO_VO.setVersion(getVersion());
|
||||||
|
break;
|
||||||
|
case "test":
|
||||||
|
SYSTEM_INFO_VO = new SystemInfoVO();
|
||||||
|
SYSTEM_INFO_VO.setActive("测 试 机");
|
||||||
|
SYSTEM_INFO_VO.setVersion(getVersion());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVO.success(SYSTEM_INFO_VO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getVersion() {
|
||||||
|
try {
|
||||||
|
// 获取当前 JAR 文件的路径
|
||||||
|
// String jarPath = TestApi.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
|
||||||
|
String jarPath = TestApi.class.getClassLoader().getResource("").toURI().getPath();
|
||||||
|
log.debug("当前jar路径:" + jarPath);
|
||||||
|
// 转换为 Path 对象
|
||||||
|
Path path = Paths.get(jarPath.substring(1));
|
||||||
|
// 获取文件属性
|
||||||
|
BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
|
||||||
|
// 获取创建时间
|
||||||
|
FileTime creationTime = attr.creationTime();
|
||||||
|
// 将 FileTime 转换为 LocalDateTime
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(creationTime.toInstant(), ZoneId.systemDefault());
|
||||||
|
// 定义日期格式
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
return localDateTime.format(formatter);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取jar信息失败", e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/29 11:46:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-material-pojo-vo-SystemInfoVO")
|
||||||
|
public class SystemInfoVO {
|
||||||
|
|
||||||
|
@ApiModelProperty("环境信息,开发机;测试机")
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
@ApiModelProperty("版本号")
|
||||||
|
private String version;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue