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

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

@ -15,13 +15,4 @@ public interface ICommonClearService
* @return
*/
public int clearTableData(String tableName);
/**
*
*
* @param tableName
* @param moduleKey
* @return
*/
public int clearTableDataWithCascade(String tableName, String moduleKey);
}

@ -33,36 +33,4 @@ public class CommonClearServiceImpl implements ICommonClearService
// 表名已在Controller层通过白名单验证这里直接执行
return commonClearMapper.clearTableData(tableName);
}
/**
*
* 使
*
* @param tableName
* @param moduleKey
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int clearTableDataWithCascade(String tableName, String moduleKey)
{
int totalDeleted = 0;
// 根据模块标识进行特殊处理
if ("sparePartsInventory".equals(moduleKey)) {
// 备件库记录:先删除明细表,再删除主表
// 1. 删除备件盘点记录明细表
int detailDeleted = commonClearMapper.clearTableData("spare_parts_inventory_check");
totalDeleted += detailDeleted;
// 2. 删除备件库记录主表
int mainDeleted = commonClearMapper.clearTableData("spare_parts_inventory");
totalDeleted += mainDeleted;
return totalDeleted;
} else {
// 其他模块使用普通删除
return commonClearMapper.clearTableData(tableName);
}
}
}

@ -26,7 +26,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDailyFaultRecordList" parameterType="DailyFaultRecord" resultMap="DailyFaultRecordResult">
<include refid="selectDailyFaultRecordVo"/>
<where>
<if test="date != null and date != ''"> and date = #{date}</if>
<!-- 日期查询:优先使用日期范围,如果没有范围则使用精确日期 -->
<choose>
<when test="params != null and ((params.beginDate != null and params.beginDate != '') or (params.endDate != null and params.endDate != ''))">
<!-- 日期范围查询 -->
<if test="params.beginDate != null and params.beginDate != '' and params.endDate != null and params.endDate != ''">
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')
</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')
</if>
</when>
<otherwise>
<!-- 精确日期查询 -->
<if test="date != null and date != ''">
and date = #{date}
</if>
</otherwise>
</choose>
<if test="location != null and location != ''"> and location like concat('%', #{location}, '%')</if>
<if test="dailyDutySupervisor != null and dailyDutySupervisor != ''"> and daily_duty_supervisor like concat('%', #{dailyDutySupervisor}, '%')</if>
<if test="tendaDailyDutySupervisor != null and tendaDailyDutySupervisor != ''"> and tenda_daily_duty_supervisor like concat('%', #{tendaDailyDutySupervisor}, '%')</if>
@ -38,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="handlingDuration != null "> and handling_duration like concat('%', #{handlingDuration}, '%')</if>
<if test="remarks != null and remarks != ''"> and remarks like concat('%', #{remarks}, '%')</if>
</where>
order by STR_TO_DATE(date, '%Y/%m/%d') desc, id desc
</select>
<select id="selectDailyFaultRecordById" parameterType="Long" resultMap="DailyFaultRecordResult">

@ -25,7 +25,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectFaultHandlingRecordList" parameterType="FaultHandlingRecord" resultMap="FaultHandlingRecordResult">
<include refid="selectFaultHandlingRecordVo"/>
<where>
<if test="faultDate != null and faultDate != ''"> and fault_date like concat('%', #{faultDate}, '%')</if>
<!-- 日期查询:优先使用日期范围,如果没有范围则使用精确日期 -->
<choose>
<when test="params != null and ((params.beginDate != null and params.beginDate != '') or (params.endDate != null and params.endDate != ''))">
<!-- 日期范围查询 -->
<if test="params.beginDate != null and params.beginDate != '' and params.endDate != null and params.endDate != ''">
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')
</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')
</if>
</when>
<otherwise>
<!-- 精确日期查询 -->
<if test="faultDate != null and faultDate != ''">
and fault_date = #{faultDate}
</if>
</otherwise>
</choose>
<if test="faultLocation != null and faultLocation != ''"> and fault_location like concat('%', #{faultLocation}, '%')</if>
<if test="handlingPersonnel != null and handlingPersonnel != ''"> and handling_personnel like concat('%', #{handlingPersonnel}, '%')</if>
<if test="faultPhenomenonAndCause != null and faultPhenomenonAndCause != ''"> and fault_phenomenon_and_cause like concat('%', #{faultPhenomenonAndCause}, '%')</if>
@ -36,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mainComponentsRepaired != null and mainComponentsRepaired != ''"> and main_components_repaired like concat('%', #{mainComponentsRepaired}, '%')</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
</where>
order by STR_TO_DATE(fault_date, '%Y/%m/%d') desc, id desc
</select>
<select id="selectFaultHandlingRecordById" parameterType="Long" resultMap="FaultHandlingRecordResult">

@ -23,7 +23,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectPowerEnergySparePartsRegistrationList" parameterType="PowerEnergySparePartsRegistration" resultMap="PowerEnergySparePartsRegistrationResult">
<include refid="selectPowerEnergySparePartsRegistrationVo"/>
<where>
<if test="date != null and date != ''"> and date like concat('%', #{date}, '%')</if>
<!-- 日期查询:优先使用日期范围,如果没有范围则使用精确日期 -->
<choose>
<when test="params != null and ((params.beginDate != null and params.beginDate != '') or (params.endDate != null and params.endDate != ''))">
<!-- 日期范围查询 -->
<if test="params.beginDate != null and params.beginDate != '' and params.endDate != null and params.endDate != ''">
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')
</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')
</if>
</when>
<otherwise>
<!-- 精确日期查询 -->
<if test="date != null and date != ''">
and date = #{date}
</if>
</otherwise>
</choose>
<if test="sparePartsName != null and sparePartsName != ''"> and spare_parts_name like concat('%', #{sparePartsName}, '%')</if>
<if test="wasteQuantity != null "> and waste_quantity like concat('%', #{wasteQuantity}, '%')</if>
<if test="storageLocation != null and storageLocation != ''"> and storage_location like concat('%', #{storageLocation}, '%')</if>
@ -32,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="sparePartModel != null and sparePartModel != ''"> and spare_part_model like concat('%', #{sparePartModel}, '%')</if>
</where>
order by STR_TO_DATE(date, '%Y/%m/%d') desc, objid desc
</select>
<select id="selectPowerEnergySparePartsRegistrationByObjid" parameterType="Long" resultMap="PowerEnergySparePartsRegistrationResult">

@ -31,7 +31,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectPowerEnergySupervisionChecklistList" parameterType="PowerEnergySupervisionChecklist" resultMap="PowerEnergySupervisionChecklistResult">
<include refid="selectPowerEnergySupervisionChecklistVo"/>
<where>
<if test="date != null and date != ''"> and date like concat('%', #{date}, '%')</if>
<!-- 日期查询:优先使用日期范围,如果没有范围则使用精确日期 -->
<choose>
<when test="params != null and ((params.beginDate != null and params.beginDate != '') or (params.endDate != null and params.endDate != ''))">
<!-- 日期范围查询 -->
<if test="params.beginDate != null and params.beginDate != '' and params.endDate != null and params.endDate != ''">
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')
</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')
</if>
</when>
<otherwise>
<!-- 精确日期查询 -->
<if test="date != null and date != ''">
and date = #{date}
</if>
</otherwise>
</choose>
<if test="jobCategory != null and jobCategory != ''"> and job_category like concat('%', #{jobCategory}, '%')</if>
<if test="jobUnit != null and jobUnit != ''"> and job_unit like concat('%', #{jobUnit}, '%')</if>
<if test="jobName != null and jobName != ''"> and job_name like concat('%', #{jobName}, '%')</if>
@ -48,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isWorkOrderClosedLoop != null and isWorkOrderClosedLoop != ''"> and is_work_order_closed_loop like concat('%', #{isWorkOrderClosedLoop}, '%')</if>
<if test="remarks != null and remarks != ''"> and remarks like concat('%', #{remarks}, '%')</if>
</where>
order by STR_TO_DATE(date, '%Y/%m/%d') desc, id desc
</select>
<select id="selectPowerEnergySupervisionChecklistById" parameterType="Long" resultMap="PowerEnergySupervisionChecklistResult">

@ -27,7 +27,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSparePartsUsageRecordList" parameterType="SparePartsUsageRecord" resultMap="SparePartsUsageRecordResult">
<include refid="selectSparePartsUsageRecordVo"/>
<where>
<if test="date != null and date != ''"> and date = #{date}</if>
<!-- 日期查询:优先使用日期范围,如果没有范围则使用精确日期 -->
<choose>
<when test="params != null and ((params.beginDate != null and params.beginDate != '') or (params.endDate != null and params.endDate != ''))">
<!-- 日期范围查询 -->
<if test="params.beginDate != null and params.beginDate != '' and params.endDate != null and params.endDate != ''">
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')
</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')
</if>
</when>
<otherwise>
<!-- 精确日期查询 -->
<if test="date != null and date != ''">
and date = #{date}
</if>
</otherwise>
</choose>
<if test="sparePartName != null and sparePartName != ''"> and spare_part_name like concat('%', #{sparePartName}, '%')</if>
<if test="sparePartModel != null and sparePartModel != ''"> and spare_part_model like concat('%', #{sparePartModel}, '%')</if>
<if test="quantityUsed != null "> and quantity_used like concat('%', #{quantityUsed}, '%')</if>
@ -40,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="departmentWarehouse != null and departmentWarehouse != ''"> and department_warehouse like concat('%', #{departmentWarehouse}, '%')</if>
<if test="remarks != null and remarks != ''"> and remarks like concat('%', #{remarks}, '%')</if>
</where>
order by STR_TO_DATE(date, '%Y/%m/%d') desc, id desc
</select>
<select id="selectSparePartsUsageRecordById" parameterType="Long" resultMap="SparePartsUsageRecordResult">

Loading…
Cancel
Save