From d3b5631c9e88c41d70b69d16d287e8109094af4c Mon Sep 17 00:00:00 2001 From: ls Date: Mon, 23 Dec 2024 14:37:37 +0800 Subject: [PATCH] update --- .../java/org/jeecg/common/util/DateUtils.java | 80 +++++++++++---- .../org/jeecg/common/util/date/TimeRange.java | 22 +++++ .../src/main/resources/logback-spring.xml | 97 ++++++------------- .../modules/database/entity/Experiment.java | 27 +++--- ...ExperimentRadiationProcessServiceImpl.java | 27 +++++- 5 files changed, 152 insertions(+), 101 deletions(-) create mode 100644 physical-base-core/src/main/java/org/jeecg/common/util/date/TimeRange.java diff --git a/physical-base-core/src/main/java/org/jeecg/common/util/DateUtils.java b/physical-base-core/src/main/java/org/jeecg/common/util/DateUtils.java index ba57e2a..5d151f4 100644 --- a/physical-base-core/src/main/java/org/jeecg/common/util/DateUtils.java +++ b/physical-base-core/src/main/java/org/jeecg/common/util/DateUtils.java @@ -1,21 +1,15 @@ package org.jeecg.common.util; import org.jeecg.common.constant.SymbolConstant; +import org.jeecg.common.util.date.TimeRange; import org.springframework.util.StringUtils; import java.beans.PropertyEditorSupport; import java.sql.Timestamp; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; +import java.text.*; +import java.time.*; import java.time.temporal.ChronoUnit; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; +import java.util.*; /** * 类描述:时间操作定义类 @@ -26,25 +20,25 @@ import java.util.GregorianCalendar; */ public class DateUtils extends PropertyEditorSupport { - public static ThreadLocal date_sdf = new ThreadLocal() { + public static ThreadLocal date_sdf = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } }; - public static ThreadLocal yyyyMMdd = new ThreadLocal() { + public static ThreadLocal yyyyMMdd = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyyMMdd"); } }; - public static ThreadLocal date_sdf_wz = new ThreadLocal() { + public static ThreadLocal date_sdf_wz = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy年MM月dd日"); } }; - public static ThreadLocal time_sdf = new ThreadLocal() { + public static ThreadLocal time_sdf = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm"); @@ -72,8 +66,8 @@ public class DateUtils extends PropertyEditorSupport { /** * 以毫秒表示的时间 */ - private static final long DAY_IN_MILLIS = 24 * 3600 * 1000; - private static final long HOUR_IN_MILLIS = 3600 * 1000; + private static final long DAY_IN_MILLIS = 24 * 3600 * 1000; + private static final long HOUR_IN_MILLIS = 3600 * 1000; private static final long MINUTE_IN_MILLIS = 60 * 1000; private static final long SECOND_IN_MILLIS = 1000; @@ -123,7 +117,6 @@ public class DateUtils extends PropertyEditorSupport { return new Date(); } - /** * 当前日期 * @@ -816,4 +809,57 @@ public class DateUtils extends PropertyEditorSupport { return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); } + /** + * 找出列表中最早的时间,比较开始时间和结束时间,返回最早的 + * + * @param timeRanges + * @return + */ + public static Date findEarliestTime(List timeRanges) { + if (timeRanges == null || timeRanges.isEmpty()) { + return null; // 处理空列表的情况 + } + return timeRanges.stream() + //过滤掉start或end为null 的数据 + .filter(timeRange -> timeRange.getStartTime() != null || timeRange.getEndTime() != null) + .flatMap(timeRange -> { + List dates = new ArrayList<>(); + if (timeRange.getStartTime() != null) { + dates.add(timeRange.getStartTime()); + } + if (timeRange.getEndTime() != null) { + dates.add(timeRange.getEndTime()); + } + return dates.stream(); + }) + .min(Date::compareTo) + .orElse(null); + } + + /** + * 找出列表中最晚的时间,比较开始时间和结束时间,返回最晚的 + * + * @param timeRanges + * @return + */ + public static Date findLatestTime(List timeRanges) { + if (timeRanges == null || timeRanges.isEmpty()) { + return null; // 处理空列表的情况 + } + return timeRanges.stream() + //过滤掉start或end为null 的数据 + .filter(timeRange -> timeRange.getStartTime() != null || timeRange.getEndTime() != null) + .flatMap(timeRange -> { + List dates = new ArrayList<>(); + if (timeRange.getStartTime() != null) { + dates.add(timeRange.getStartTime()); + } + if (timeRange.getEndTime() != null) { + dates.add(timeRange.getEndTime()); + } + return dates.stream(); + }) + .max(Date::compareTo) + .orElse(null); + } } \ No newline at end of file diff --git a/physical-base-core/src/main/java/org/jeecg/common/util/date/TimeRange.java b/physical-base-core/src/main/java/org/jeecg/common/util/date/TimeRange.java new file mode 100644 index 0000000..f2314b0 --- /dev/null +++ b/physical-base-core/src/main/java/org/jeecg/common/util/date/TimeRange.java @@ -0,0 +1,22 @@ +/* + * Ant Group + * Copyright (c) 2004-2024 All Rights Reserved. + */ +package org.jeecg.common.util.date; + +import lombok.*; + +import java.util.Date; + +/** + * @author lise + * @version TimeRange.java, v 0.1 2024年12月23日 14:21 lise + */ +@Getter +@Setter +@AllArgsConstructor +public class TimeRange { + private Date startTime; + private Date endTime; + +} \ No newline at end of file diff --git a/physical-launcher/src/main/resources/logback-spring.xml b/physical-launcher/src/main/resources/logback-spring.xml index 0ff9b35..bab5f96 100644 --- a/physical-launcher/src/main/resources/logback-spring.xml +++ b/physical-launcher/src/main/resources/logback-spring.xml @@ -1,82 +1,47 @@ - - - + + + + - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n + + + + + + + + + ${CONSOLE_LOG_PATTERN} - + - - - ${LOG_HOME}/physical-%d{yyyy-MM-dd}.%i.log - - 30 - 10MB + ${LOG_FILE_PATH}/${LOG_FILE_NAME} + + ${LOG_ARCHIVE_PATH}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.%i.log + + 100MB + + 30 - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n + + ${FILE_LOG_PATTERN} - - - - - ERROR - - - - ${LOG_HOME}/physical-error-%d{yyyy-MM-dd}.%i.log - - 30 - 10MB - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n - - - + + - - - - - ${LOG_HOME}/physical-%d{yyyy-MM-dd}.%i.html - - 30 - 10MB - - - - %p%d%msg%M%F{32}%L - - - - + + + - - - - - - - + - - - - + + \ No newline at end of file diff --git a/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/entity/Experiment.java b/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/entity/Experiment.java index e5ccc62..e1055af 100644 --- a/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/entity/Experiment.java +++ b/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/entity/Experiment.java @@ -129,33 +129,33 @@ public class Experiment implements Serializable { /** * 样品信息 */ - @Excel(name = "样品信息", width = 15) - @Schema(description = "样品信息") - private String sampleInfo; + //@Excel(name = "样品信息", width = 15) + //@Schema(description = "样品信息") + //private String sampleInfo; @TableField(exist = false) private List sampleInfoList; /** * 辐照板 */ - @Excel(name = "辐照板", width = 15) - @Schema(description = "辐照板") - private String irradiationBoard; + //@Excel(name = "辐照板", width = 15) + //@Schema(description = "辐照板") + //private String irradiationBoard; @TableField(exist = false) private List irradiationBoardList; /** * 偏置条件 */ - @Excel(name = "偏置条件", width = 15) - @Schema(description = "偏置条件") - private String deviationCondition; + //@Excel(name = "偏置条件", width = 15) + //@Schema(description = "偏置条件") + //private String deviationCondition; @TableField(exist = false) private List deviationConditionList; /** * 加偏设备 */ - @Excel(name = "加偏设备", width = 15) - @Schema(description = "加偏设备") - private String deviationEquipment; + //@Excel(name = "加偏设备", width = 15) + //@Schema(description = "加偏设备") + //private String deviationEquipment; /** * 加偏设备 */ @@ -170,7 +170,7 @@ public class Experiment implements Serializable { /** * 试验文件 */ - @Excel(name = "试验文件", width = 15) + //@Excel(name = "试验文件", width = 15) @Schema(description = "试验文件") private String files; @@ -185,6 +185,7 @@ public class Experiment implements Serializable { * 试验负责人 */ @TableField(exist = false) + @Excel(name = "试验负责人", width = 15) private String supervisorName; /** * 试验人员 diff --git a/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentRadiationProcessServiceImpl.java b/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentRadiationProcessServiceImpl.java index df6ac1c..b49d0bb 100644 --- a/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentRadiationProcessServiceImpl.java +++ b/physical-module-system/physical-system-biz/src/main/java/org/jeecg/modules/database/service/impl/ExperimentRadiationProcessServiceImpl.java @@ -1,13 +1,14 @@ package org.jeecg.modules.database.service.impl; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; -import org.jeecg.modules.database.entity.ExperimentRadiationProcess; -import org.jeecg.modules.database.entity.ExperimentSampleInfo; +import org.jeecg.common.util.DateUtils; +import org.jeecg.common.util.date.TimeRange; +import org.jeecg.modules.database.entity.*; import org.jeecg.modules.database.mapper.ExperimentRadiationProcessMapper; -import org.jeecg.modules.database.service.IExperimentRadiationProcessService; -import org.jeecg.modules.database.service.IExperimentSampleInfoService; +import org.jeecg.modules.database.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,7 +26,9 @@ import java.util.stream.Collectors; public class ExperimentRadiationProcessServiceImpl extends ServiceImpl implements IExperimentRadiationProcessService { @Autowired - private IExperimentSampleInfoService experimentSampleInfoService; + private IExperimentSampleInfoService experimentSampleInfoService; + @Autowired + private IExperimentIrradiationBoardService experimentIrradiationBoardService; @Override public List getByExperimentId(String experimentId) { @@ -68,6 +71,20 @@ public class ExperimentRadiationProcessServiceImpl extends ServiceImpl radiationProcessList = getByExperimentId(experimentRadiationProcess.getExperimentId()); + if (CollUtil.isNotEmpty(radiationProcessList)) { + List list = radiationProcessList.stream().map(v -> new TimeRange(v.getRadiationStartTime(), v.getRadiationEndTime())) + .collect(Collectors.toList()); + Date earliestTime = DateUtils.findEarliestTime(list); + Date latestTime = DateUtils.findLatestTime(list); + List irradiationBoardList = experimentIrradiationBoardService.getByExperimentId( + experimentRadiationProcess.getExperimentId()); + String mv = DateUtils.formatDate(earliestTime, "yyyy-MM-dd") + "至" + DateUtils.formatDate(latestTime, "yyyy-MM-dd"); + irradiationBoardList.forEach(experimentIrradiationBoard -> { + experimentIrradiationBoard.setMeasurementValidity(mv); + experimentIrradiationBoardService.saveOrUpdate(experimentIrradiationBoard); + }); + } experimentRadiationProcess.setSampleInfo(StringUtils.join(sampleInfoIds, ",")); saveOrUpdate(experimentRadiationProcess);