时间段查询(数据库中指定一个时间点)

数据库时间点字段rectifyNotifyDate和delDate

在实体类中增加四个时间段属性rectifyStartTime,rectifyEndTime,abandonStartTime,abandonEndTime

前台通过表单提交数据即可

前台代码

               <div style="float: right;margin:5px 5px;">    
                <span>整改通知时间:</span>
                <input class="Wdate"
                    style="border: 1px solid #e5e6e7;padding:15px 0 15px 10px;"
                    name="rectifyStartTime" type="text" value="${gasRectifyNotify.rectifyStartTime}"
                    placeholder="请选择日期"
                    onclick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
                
                <input class="Wdate"
                    style="border: 1px solid #e5e6e7;padding:15px 0 15px 10px;"
                    name="rectifyEndTime" type="text" value="${gasRectifyNotify.rectifyEndTime}"
                     placeholder="请选择日期"
                    onclick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
              </div>
              
              
              <div style="float: right;margin:5px 5px;"> 
              <span>废弃时间:</span>
                <input class="Wdate"
                    style="border: 1px solid #e5e6e7;padding:15px 0 15px 10px;"
                    name="abandonStartTime" type="text" value="${gasRectifyNotify.abandonStartTime}"
                    placeholder="请选择日期"
                    onclick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
                
                <input class="Wdate"
                    style="border: 1px solid #e5e6e7;padding:15px 0 15px 10px;"
                    name="abandonEndTime" type="text" value="${gasRectifyNotify.abandonEndTime}"
                     placeholder="请选择日期"
                    onclick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
              </div>
                

mapper中代码

<if test="rectifyStartTime != null and rectifyStartTime != ''">
            <![CDATA[
                AND rectifyNotifyDate <=#{rectifyStartTime}
            ]]>
        </if>
        <if test="rectifyEndTime != null and rectifyEndTime != ''">
            <![CDATA[
                AND rectifyNotifyDate>=#{rectifyStartTime}
            ]]>
        </if>
        
        
        <if test="abandonStartTime != null and abandonStartTime != ''">
            <![CDATA[
                AND delDate <=#{abandonStartTime}
            ]]>
        </if>
        <if test="abandonEndTime != null and abandonEndTime != ''">
            <![CDATA[
                AND delDate >=#{abandonStartTime}
            ]]>
        </if>

猜你喜欢

转载自blog.csdn.net/zzh8578741/article/details/82976855