diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/DateConstant.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/DateConstant.java new file mode 100644 index 0000000..d931e9d --- /dev/null +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/DateConstant.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.common.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @author hx + */ +public interface DateConstant { + + @AllArgsConstructor + enum UnitEnum { + YEAR("year","年"), + MONTH("month","月"), + DAY("day","日"), + HOUR("hour","时"), + MINUTER("minuter","分"), + SECOND("second","秒") + ; + + @Getter + private String unit; + @Getter + private String describe; + + public static UnitEnum getEnumByUnit(String unit) { + Optional optionalUnitEnum = Arrays.stream(UnitEnum.class.getEnumConstants()) + .filter(unitEnum -> unit.equals(unitEnum.getUnit())).findAny(); + return optionalUnitEnum.orElse(null); + } + } + +} diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java index 5caec28..15c87dc 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java @@ -1,6 +1,9 @@ package com.hnac.hzims.common.utils; +import com.hnac.hzims.common.constant.DateConstant; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.util.Assert; import java.time.*; import java.time.temporal.ChronoUnit; @@ -98,7 +101,7 @@ public class DateUtil { * @param timeUnit 时间单位 * @return */ - /*public static LocalDateTime plus(LocalDateTime date, Integer duration, String timeUnit) { + public static LocalDateTime plus(LocalDateTime date, Integer duration, String timeUnit) { DateConstant.UnitEnum enumByUnit = DateConstant.UnitEnum.getEnumByUnit(timeUnit); Assert.isTrue(ObjectUtil.isNotEmpty(enumByUnit),() -> { throw new ServiceException("DateUtil.plus内传入的时间单位参数在枚举类中未查询到,传入的参数为:" + timeUnit); @@ -119,5 +122,5 @@ public class DateUtil { default: return null; } - }*/ + } } diff --git a/hzims-service-api/pom.xml b/hzims-service-api/pom.xml index ddccc54..370bde6 100644 --- a/hzims-service-api/pom.xml +++ b/hzims-service-api/pom.xml @@ -18,12 +18,12 @@ assets-api - spare-api + topvision-api equipment-api safeproduct-api hzims-operational-api - inspect-api + message-api ticket-api weather-api diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index 031a0c6..f4231c0 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -25,7 +25,7 @@ safeproduct operational - + message ticket weather