完成借阅信息查询,能查询未超期未还的

pull/1/head
you 5 years ago
parent d635a45a08
commit d4720ac1d1

@ -24,6 +24,7 @@
<div class="layui-inline">
<select id="condition" name="condition" lay-verify="required">
<option value=""></option>
<option value="other">超期未还</option>
<option value="id">ID</option>
<option value="card_id">借阅证号</option>
<option value="book_id">书籍ID</option>
@ -38,13 +39,6 @@
<input class="layui-input" id="conditionValue" name="conditionValue" id="demoReload" autocomplete="off">
</div>
<button class="layui-btn" name="condition" data-type="reload" lay-event="search">搜索</button>
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i></button>
</script>
<!-- 表格后面的操作 -->
<script type="text/html" id="operateBar">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
layui.use(['table','jquery'], function(){
@ -58,13 +52,12 @@
,cols: [[
{field:'id', width:80, title: 'ID', sort: true}
,{field:'card_id', width:180, title: '借阅证号'}
,{field:'book_id', width:180, title: '书籍id', sort: true}
,{field:'book_id', width:100, title: '书籍ID', sort: true}
,{field:'borrow_date', width:180, title: '借阅时间'}
,{field:'end_date', title: '限定时间', minWidth: 150}
,{field:'end_date', title: '限定时间', width: 180}
,{field:'return_date', width:180, title: '归还时间', sort: true}
,{field:'illegal', width:80, title: '违章信息', sort: true}
,{field:'illegal', width:280, title: '违章信息', sort: true}
,{field:'manager_id', width:80, title: '处理人'}
,{fixed: 'right', title:'操作', toolbar: '#operateBar', align: 'center', width:150}
]]
,page: true
});
@ -77,7 +70,6 @@
case 'search':
var conditionValue = $('#conditionValue');
var condition = $('#condition');
layer.msg(condition.val());
// 进行搜索,重新渲染
tableIns.reload({
where: { //设定异步数据接口的额外参数,任意设
@ -89,38 +81,11 @@
}
});
break;
// 添加借书证
case 'add':
var addCardLayer = layer.open({
type: 2,
title: '添加借书证',
area: ['800px', '500px'],
maxmin: true,
shadeClose: true,
content: 'cardadd.jsp',
});
//layer.full(addCardLayer);
};
});
// 侧边工具栏事件
table.on(('tool(formFilter)'), function(obj){
var data = obj.data;
var layEvent = obj.event;
var tr = obj.tr;
switch(obj.event){
case 'edit':
layer.open({
type: 2,
title: '更改信息',
area: ['800px', '600px'],
maxmin: true,
shadeClose: true,
content: '',
})
break;
}
})
});
</script>
</body>

@ -1,3 +1,9 @@
<%@page import="javabean.Util"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="com.mysql.jdbc.Connection"%>
<%@page import="javabean.Base"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="javabean.JDBCBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
@ -14,53 +20,62 @@
</style>
</head>
<body>
<%
String id = request.getParameter("id");
Connection connection = (Connection)Base.getConnection();
String sql = "select * from borrow_books,books where card_id=? and borrow_books.book_id = books.id";
PreparedStatement pstmt = connection.prepareStatement(sql);
pstmt.setString(1, id);
ResultSet resultSet = null;
resultSet = pstmt.executeQuery();
%>
<div class="layui-form">
<table class="layui-table">
<colgroup>
<col width="150">
<col width="150">
<col width="200">
<col width="200">
<col width="200">
<col width="200">
<col width="220">
<col width="200">
<col>
</colgroup>
<thead>
<tr>
<th>人物</th>
<th>民族</th>
<th>出场时间</th>
<th>格言</th>
<th>ID</th>
<th>书籍ID</th>
<th>书籍名</th>
<th>借阅时间</th>
<th>截止时间</th>
<th>归还时间</th>
<th>违规信息</th>
<th>处理人</th>
</tr>
</thead>
<tbody>
<%
System.out.println(Util.getCurrentTimeString());
%>
<% while(resultSet.next()){ %>
<%-- 图书超期 --%>
<%if(Util.getFormatDateTime(resultSet.getString("end_date")).compareTo(Util.getCurrentTimeString()) < 0 && resultSet.getString("return_date") == null){ %>
<tr style="color:#FF5722;">
<%} else{ %>
<tr>
<td>贤心</td>
<td>汉族</td>
<td>1989-10-14</td>
<td>人生似修行</td>
</tr>
<tr>
<td>张爱玲</td>
<td>汉族</td>
<td>1920-09-30</td>
<td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
</tr>
<tr>
<td>Helen Keller</td>
<td>拉丁美裔</td>
<td>1880-06-27</td>
<td> Life is either a daring adventure or nothing.</td>
</tr>
<tr>
<td>岳飞</td>
<td>汉族</td>
<td>1103-北宋崇宁二年</td>
<td>教科书再滥改,也抹不去“民族英雄”的事实</td>
</tr>
<tr>
<td>孟子</td>
<td>华夏族(汉族)</td>
<td>公元前-372年</td>
<td>猿强,则国强。国强,则猿更强! </td>
<%} %>
<td><%=resultSet.getString("card_id") %></td>
<td><%=resultSet.getString("id") %></td>
<td><%=resultSet.getString("books.name") %></td>
<td><%=Util.getFormatDateTime(resultSet.getString("borrow_date")) %></td>
<td><%=Util.getFormatDateTime(resultSet.getString("end_date"))%></td>
<td><%=resultSet.getString("return_date")!=null?Util.getFormatDateTime(resultSet.getString("return_date")) : "未归还" %></td>
<td><%=resultSet.getString("illegal")!=null?resultSet.getString("illegal"):""%></td>
<td><%=resultSet.getString("manager_id")!=null?resultSet.getString("manager_id"):"" %></td>
</tr>
<%} %>
</tbody>
</table>
</div>

@ -1,5 +1,7 @@
package javabean;
import java.text.SimpleDateFormat;
public class Util {
/**
* json
@ -11,7 +13,31 @@ public class Util {
int count = ( str.length()-str.replace(contain, "").length() ) / contain.length();
return count;
}
/**
* datetime .0 ,
* @param dateTime
* @return
*/
public static String getFormatDateTime(String dateTime) {
if(dateTime != null && dateTime.indexOf(".0") != -1) {
return dateTime.substring(0, dateTime.length()-2);
}else if(dateTime != null) {
return dateTime;
}
return null;
}
public static String getCurrentTimeString() {
java.util.Date date = new java.util.Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return dateFormat.format(date);
}
public static void main(String[] args) {
System.out.println(Util.getCountString("234{sdf{sdf{", "{"));
java.util.Date date = new java.util.Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(dateFormat.format(date));
}
}

@ -68,7 +68,6 @@ public class BookList extends HttpServlet {
json.put("code", 0);
json.put("msg", "success");
json.put("count", map.get("count"));
System.out.println("count: " +map.get("count"));
result = "[" +result +"]";
json.put("data", result);
}

@ -55,12 +55,20 @@ public class BorrowList extends HttpServlet {
// 进行查询
try {
connection = (Connection) Base.getConnection();
sql = "select * from borrow_books ";
sql = "select id, card_id, book_id, "
+ "DATE_FORMAT(borrow_date, '%Y-%m-%d %k:%i:%s') as borrow_date, "
+ "DATE_FORMAT(return_date, '%Y-%m-%d %k:%i:%s') as return_date, "
+ "DATE_FORMAT(end_date, '%Y-%m-%d %k:%i:%s') as end_date,"
+ "illegal, manager_id "
+ "from borrow_books";
if(condition!=null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {
where = " where "+ condition +" like '%" +conditionValue +"%' ";
sql += where;
}else if(condition!=null && condition.equals("other")) {
where = " where return_date is null and curtime()>end_date ";
sql +=where;
}
sql += " limit ?,?";//1 10 (1-1)*10
sql += " limit ?,?";//1 10 (1-1)*10;
pstmt = connection.prepareStatement(sql);
pstmt.setInt(1, (Integer.parseInt(page)-1) * Integer.parseInt(limit));
pstmt.setInt(2, Integer.parseInt(limit));
@ -86,6 +94,9 @@ public class BorrowList extends HttpServlet {
if(!jsonArray.isEmpty()) {
code = 0;
msg = "查询成功";
}else {
code = 0;
msg = "没有数据";
}
} catch (ClassNotFoundException e) {

Loading…
Cancel
Save