feat(ems): 增加日期范围查询功能

- 在多个页面中添加日期范围选择器,支持开始日期和结束日期的选择- 后端 mapper 文件中增加对日期范围查询的支持
-优化查询逻辑,优先使用日期范围进行筛选
- 调整表格样式,增加行hover效果
boardTest
zch 2 weeks ago
parent 90b2d9e3b3
commit c37ef20af2

@ -55,9 +55,12 @@ public class DailyFaultRecord extends BaseEntity
private String handlingCompletionTime;
/** 处置时长 */
@Excel(name = "处置时长" , cellType = Excel.ColumnType.NUMERIC)
private Long handlingDuration;
/** 处置时长格式化显示 (HH:mm:ss) */
@Excel(name = "处置时长", cellType = Excel.ColumnType.STRING,type = Excel.Type.EXPORT)
private String handlingDurationFormatted;
/** 备注 */
@Excel(name = "备注", cellType = Excel.ColumnType.STRING)
private String remarks;
@ -155,12 +158,42 @@ public class DailyFaultRecord extends BaseEntity
public void setHandlingDuration(Long handlingDuration)
{
this.handlingDuration = handlingDuration;
// 自动格式化处置时长
this.handlingDurationFormatted = formatDuration(handlingDuration);
}
public Long getHandlingDuration()
{
return handlingDuration;
}
public void setHandlingDurationFormatted(String handlingDurationFormatted)
{
this.handlingDurationFormatted = handlingDurationFormatted;
}
public String getHandlingDurationFormatted()
{
return handlingDurationFormatted;
}
/**
* HH:mm:ss
* @param seconds
* @return
*/
private String formatDuration(Long seconds) {
if (seconds == null || seconds <= 0) {
return "00:00:00";
}
long hours = seconds / 3600;
long minutes = (seconds % 3600) / 60;
long secs = seconds % 60;
return String.format("%02d:%02d:%02d", hours, minutes, secs);
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
@ -185,6 +218,7 @@ public class DailyFaultRecord extends BaseEntity
.append("faultOccurrenceTime", getFaultOccurrenceTime())
.append("handlingCompletionTime", getHandlingCompletionTime())
.append("handlingDuration", getHandlingDuration())
.append("handlingDurationFormatted", getHandlingDurationFormatted())
.append("remarks", getRemarks())
.toString();
}

@ -42,7 +42,14 @@ public class DailyFaultRecordServiceImpl implements IDailyFaultRecordService
@Override
public List<DailyFaultRecord> selectDailyFaultRecordList(DailyFaultRecord dailyFaultRecord)
{
return dailyFaultRecordMapper.selectDailyFaultRecordList(dailyFaultRecord);
List<DailyFaultRecord> list = dailyFaultRecordMapper.selectDailyFaultRecordList(dailyFaultRecord);
// 确保格式化字段正确设置(防止数据库查询未正确设置的情况)
for (DailyFaultRecord record : list) {
if (record.getHandlingDurationFormatted() == null && record.getHandlingDuration() != null) {
record.setHandlingDuration(record.getHandlingDuration()); // 触发格式化
}
}
return list;
}
/**
@ -54,6 +61,10 @@ public class DailyFaultRecordServiceImpl implements IDailyFaultRecordService
@Override
public int insertDailyFaultRecord(DailyFaultRecord dailyFaultRecord)
{
// 确保格式化字段正确设置
if (dailyFaultRecord.getHandlingDuration() != null) {
dailyFaultRecord.setHandlingDuration(dailyFaultRecord.getHandlingDuration());
}
return dailyFaultRecordMapper.insertDailyFaultRecord(dailyFaultRecord);
}
@ -66,6 +77,10 @@ public class DailyFaultRecordServiceImpl implements IDailyFaultRecordService
@Override
public int updateDailyFaultRecord(DailyFaultRecord dailyFaultRecord)
{
// 确保格式化字段正确设置
if (dailyFaultRecord.getHandlingDuration() != null) {
dailyFaultRecord.setHandlingDuration(dailyFaultRecord.getHandlingDuration());
}
return dailyFaultRecordMapper.updateDailyFaultRecord(dailyFaultRecord);
}
@ -120,6 +135,11 @@ public class DailyFaultRecordServiceImpl implements IDailyFaultRecordService
// 设置操作人
record.setCreateBy(operName);
// 确保格式化字段正确设置
if (record.getHandlingDuration() != null) {
record.setHandlingDuration(record.getHandlingDuration());
}
// 验证是否存在这个记录
DailyFaultRecord existRecord = null;
if (StringUtils.isNotEmpty(record.getDate()) && StringUtils.isNotEmpty(record.getLocation()))

@ -16,11 +16,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="faultOccurrenceTime" column="fault_occurrence_time" />
<result property="handlingCompletionTime" column="handling_completion_time" />
<result property="handlingDuration" column="handling_duration" />
<result property="handlingDurationFormatted" column="handling_duration_formatted" />
<result property="remarks" column="remarks" />
</resultMap>
<sql id="selectDailyFaultRecordVo">
select id, date, location, daily_duty_supervisor, tenda_daily_duty_supervisor, fault_situation, handling_measures, fault_type, fault_occurrence_time, handling_completion_time, handling_duration, remarks from daily_fault_record
select id, date, location, daily_duty_supervisor, tenda_daily_duty_supervisor, fault_situation, handling_measures, fault_type, fault_occurrence_time, handling_completion_time, handling_duration,
CASE
WHEN handling_duration IS NULL OR handling_duration &lt;= 0 THEN '00:00:00'
ELSE CONCAT(
LPAD(FLOOR(handling_duration / 3600), 2, '0'), ':',
LPAD(FLOOR((handling_duration % 3600) / 60), 2, '0'), ':',
LPAD(handling_duration % 60, 2, '0')
)
END as handling_duration_formatted,
remarks from daily_fault_record
</sql>
<select id="selectDailyFaultRecordList" parameterType="DailyFaultRecord" resultMap="DailyFaultRecordResult">
@ -34,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and STR_TO_DATE(date, '%Y/%m/%d') BETWEEN STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d') AND STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')
</if>
<if test="params.beginDate != null and params.beginDate != '' and (params.endDate == null or params.endDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') >= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
and STR_TO_DATE(date, '%Y/%m/%d') &gt;= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
</if>
<if test="params.endDate != null and params.endDate != '' and (params.beginDate == null or params.beginDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') &lt;= STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')
@ -94,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<choose>
<when test="faultOccurrenceTime != null and handlingCompletionTime != null and faultOccurrenceTime != '' and handlingCompletionTime != ''">
CASE
WHEN TIME_TO_SEC(#{handlingCompletionTime}) >= TIME_TO_SEC(#{faultOccurrenceTime}) THEN
WHEN TIME_TO_SEC(#{handlingCompletionTime}) &gt;= TIME_TO_SEC(#{faultOccurrenceTime}) THEN
TIME_TO_SEC(#{handlingCompletionTime}) - TIME_TO_SEC(#{faultOccurrenceTime})
ELSE
TIME_TO_SEC(#{handlingCompletionTime}) + 86400 - TIME_TO_SEC(#{faultOccurrenceTime})
@ -124,7 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<choose>
<when test="faultOccurrenceTime != null and handlingCompletionTime != null and faultOccurrenceTime != '' and handlingCompletionTime != ''">
CASE
WHEN TIME_TO_SEC(#{handlingCompletionTime}) >= TIME_TO_SEC(#{faultOccurrenceTime}) THEN
WHEN TIME_TO_SEC(#{handlingCompletionTime}) &gt;= TIME_TO_SEC(#{faultOccurrenceTime}) THEN
TIME_TO_SEC(#{handlingCompletionTime}) - TIME_TO_SEC(#{faultOccurrenceTime})
ELSE
TIME_TO_SEC(#{handlingCompletionTime}) + 86400 - TIME_TO_SEC(#{faultOccurrenceTime})

@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and STR_TO_DATE(fault_date, '%Y/%m/%d') BETWEEN STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d') AND STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')
</if>
<if test="params.beginDate != null and params.beginDate != '' and (params.endDate == null or params.endDate == '')">
and STR_TO_DATE(fault_date, '%Y/%m/%d') >= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
and STR_TO_DATE(fault_date, '%Y/%m/%d') &gt;= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
</if>
<if test="params.endDate != null and params.endDate != '' and (params.beginDate == null or params.beginDate == '')">
and STR_TO_DATE(fault_date, '%Y/%m/%d') &lt;= STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')

@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and STR_TO_DATE(date, '%Y/%m/%d') BETWEEN STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d') AND STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')
</if>
<if test="params.beginDate != null and params.beginDate != '' and (params.endDate == null or params.endDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') >= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
and STR_TO_DATE(date, '%Y/%m/%d') &gt;= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
</if>
<if test="params.endDate != null and params.endDate != '' and (params.beginDate == null or params.beginDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') &lt;= STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')

@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and STR_TO_DATE(date, '%Y/%m/%d') BETWEEN STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d') AND STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')
</if>
<if test="params.beginDate != null and params.beginDate != '' and (params.endDate == null or params.endDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') >= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
and STR_TO_DATE(date, '%Y/%m/%d') &gt;= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
</if>
<if test="params.endDate != null and params.endDate != '' and (params.beginDate == null or params.beginDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') &lt;= STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')

@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and STR_TO_DATE(date, '%Y/%m/%d') BETWEEN STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d') AND STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')
</if>
<if test="params.beginDate != null and params.beginDate != '' and (params.endDate == null or params.endDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') >= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
and STR_TO_DATE(date, '%Y/%m/%d') &gt;= STR_TO_DATE(#{params.beginDate}, '%Y/%m/%d')
</if>
<if test="params.endDate != null and params.endDate != '' and (params.beginDate == null or params.beginDate == '')">
and STR_TO_DATE(date, '%Y/%m/%d') &lt;= STR_TO_DATE(#{params.endDate}, '%Y/%m/%d')

Loading…
Cancel
Save