Browse Source

# common包下缺失代码提交

# service-api添加子模块message-api
zhongwei
H.X 2 years ago
parent
commit
9ab8bbd186
  1. 36
      hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/DateConstant.java
  2. 7
      hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java
  3. 4
      hzims-service-api/pom.xml
  4. 2
      hzims-service/pom.xml

36
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<UnitEnum> optionalUnitEnum = Arrays.stream(UnitEnum.class.getEnumConstants())
.filter(unitEnum -> unit.equals(unitEnum.getUnit())).findAny();
return optionalUnitEnum.orElse(null);
}
}
}

7
hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/DateUtil.java

@ -1,6 +1,9 @@
package com.hnac.hzims.common.utils; 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.springblade.core.tool.utils.ObjectUtil;
import org.springframework.util.Assert;
import java.time.*; import java.time.*;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
@ -98,7 +101,7 @@ public class DateUtil {
* @param timeUnit 时间单位 * @param timeUnit 时间单位
* @return * @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); DateConstant.UnitEnum enumByUnit = DateConstant.UnitEnum.getEnumByUnit(timeUnit);
Assert.isTrue(ObjectUtil.isNotEmpty(enumByUnit),() -> { Assert.isTrue(ObjectUtil.isNotEmpty(enumByUnit),() -> {
throw new ServiceException("DateUtil.plus内传入的时间单位参数在枚举类中未查询到,传入的参数为:" + timeUnit); throw new ServiceException("DateUtil.plus内传入的时间单位参数在枚举类中未查询到,传入的参数为:" + timeUnit);
@ -119,5 +122,5 @@ public class DateUtil {
default: default:
return null; return null;
} }
}*/ }
} }

4
hzims-service-api/pom.xml

@ -18,12 +18,12 @@
<modules> <modules>
<module>assets-api</module> <module>assets-api</module>
<module>spare-api</module> <!-- <module>spare-api</module>-->
<module>topvision-api</module> <module>topvision-api</module>
<module>equipment-api</module> <module>equipment-api</module>
<module>safeproduct-api</module> <module>safeproduct-api</module>
<module>hzims-operational-api</module> <module>hzims-operational-api</module>
<module>inspect-api</module> <!-- <module>inspect-api</module>-->
<module>message-api</module> <module>message-api</module>
<module>ticket-api</module> <module>ticket-api</module>
<module>weather-api</module> <module>weather-api</module>

2
hzims-service/pom.xml

@ -25,7 +25,7 @@
<module>safeproduct</module> <module>safeproduct</module>
<module>operational</module> <module>operational</module>
<!-- <module>inspect</module>--> <!-- <module>inspect</module>-->
<!-- <module>message</module>--> <module>message</module>
<module>ticket</module> <module>ticket</module>
<module>weather</module> <module>weather</module>
</modules> </modules>

Loading…
Cancel
Save