嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
实施厕位管理系统,一方面可以提高厕位的周转率,实现厕位的高效利用,给用户群众提供更好的服务,提高地方和城市的卫生形象;另一方面为了给管理方提供管理的依据和改进提高的空间。城市在发展旅游业之时,往往会对城市各方面的旅游问题进行改进,但公共厕所的厕位不足问题很难解决,同时公共厕所的卫生问题也是一大难题。想要解决这些困难只能是打破原先对公共厕所管理的态度。以用户为主导,提供用户需要的一切信息。只要让用户明白厕位情况,就能很大程度上缓解厕位紧张的情况,同时也能提高游客对城市卫生的感官。本系统的开发是以先进的感应系统和计算机技术相结合,构建一个易用的软件系统,最大限度为用户节约时间成本,以提升用户体验为最优化目标。
2.2 功能需求
本系统的开发严格按照用户需要为依托,分析需求得到以下需求:
1.用户登陆需求:用户和管理员的登录,根据后台设置的权限,根据用户和管理员不同的权限进入不同的页面的功能。管理员可以使用该系统后台的所有功能,而个人用户只能登陆前台查看显示的厕位信息。
2.地点确定需求:确定用户所在地点,并根据地点显示附近的厕位。
3.厕位信息显示需求:显示所在地点的厕位使用情况,厕位详细地点,是否正在被使用,已使用多少时间。
4.厕位管理需求:可以查看厕位详细信息,如厕位服务状态,上一次清扫时间,下一次清扫时间,保洁员姓名,保洁员电话
5.广告功能需求:在程序中需要有足够的广告位用于广告位招租,广告位位置合理不会干扰用户正常使用
package cn.javaee.dao.daoimpl;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import cn.javaee.bean.Position;
import cn.javaee.bean.Toilet;
import cn.javaee.dao.dao.PositionDAO;
import cn.javaee.utils.TimeUtils;
public class PositionDAOImpl extends BaseDAOImpl implements PositionDAO{
public boolean save(Position entity) {
String sql = "insert into position (isUsing, isServing,start_time,type,toiletid) values(?,?,?,?,?)";
System.out.println(entity.getStart_time());
System.out.println(entity.getType());
try (Connection connection = ds.getConnection();
PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setBoolean(1, entity.isUsing());
ps.setBoolean(2, entity.isServing());
ps.setTimestamp(3,null);
ps.setString(4, entity.getType());
ps.setInt(5, entity.getToilet().getId());
ps.executeUpdate();
return true;
} catch(SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean delete(int id) {
String sql = "delete from position where id=\"" id "\"";
return execsql(sql);
}
@Override
public boolean update(Position entity) {
String sql = "UPDATE position SET isUsing=? , isServing=?,start_time=?,type=?,toiletid=? "
"WHERE id=?";
try (Connection connection = ds.getConnection();
PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setBoolean(1, entity.isUsing());
ps.setBoolean(2, entity.isServing());
ps.setTimestamp(3, new Timestamp(TimeUtils.stringToMiles(entity.getStart_time())));
ps.setString(4, entity.getType());
ps.setInt(5, entity.getToilet().getId());
ps.setInt(6, entity.getId());
ps.executeUpdate();
return true;
} catch(SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public Position getById(int id) {
String sql = "select * from position where id=" id;
try (Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
return getPositionBySql(rs);
}
}catch (SQLException e) {
e.printStackTrace();
return null;
}
return null;
}
public Position getPositionBySql(ResultSet rs) {
Position position = new Position();
try {
position.setId(rs.getInt("id"));
position.setUsing(rs.getBoolean("isUsing"));
position.setServing(rs.getBoolean("isServing"));
position.setStart_time(TimeUtils.dateToString((java.util.Date)rs.getTimestamp("start_time")));
position.setType(rs.getString("type"));
ToiletDAOImpl toiletDAOImpl = new ToiletDAOImpl();
position.setToilet(toiletDAOImpl.getById(rs.getInt("toiletid")));
return position;
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
@Override
public List<Position> getById(int[] ids) {
// 不做
return null;
}
@Override
public List<Position> getAll() {
String sql = "select * from position";
return getPositionList(sql);
}
public List<Position> getPositionByToilet(int id) {
String sql = "select * from position where toiletid=" id;
return getPositionList(sql);
}
public List<Position> getPositionList(String sql) {
List<Position>positions = new ArrayList<>();
try(Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery()) {
while(rs.next()) {
positions.add(getPositionBySql(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return positions;
}
@Override
public void setUsing(boolean isUsing, int id) {
String sql = "UPDATE position SET isUsing=?,start_time=?,WHERE id = ?";
Timestamp date = new Timestamp(System.currentTimeMillis());
try (Connection connection = ds.getConnection();
PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setBoolean(1,isUsing);
ps.setInt(2, id);
ps.setTimestamp(3,date);
ps.executeUpdate();
} catch(SQLException e) {
e.printStackTrace();
}
}
}
图5-1移动端厕位浏览界面
5.2 移动端详细厕位信息模块实现
此模块主要是为了使用户能够点击厕位查看厕位详细信息,厕位详细信息实现的代码如下:
package cn.javaee.dao.daoimpl;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import cn.javaee.bean.Position;
import cn.javaee.bean.Toilet;
import cn.javaee.dao.dao.PositionDAO;
import cn.javaee.utils.TimeUtils;
public class PositionDAOImpl extends BaseDAOImpl implements PositionDAO{
public boolean save(Position entity) {
String sql = "insert into position (isUsing, isServing,start_time,type,toiletid) values(?,?,?,?,?)";
System.out.println(entity.getStart_time());
System.out.println(entity.getType());
try (Connection connection = ds.getConnection();
PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setBoolean(1, entity.isUsing());
ps.setBoolean(2, entity.isServing());
ps.setTimestamp(3,null);
ps.setString(4, entity.getType());
ps.setInt(5, entity.getToilet().getId());
ps.executeUpdate();
return true;
} catch(SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean delete(int id) {
String sql = "delete from position where id=\"" id "\"";
return execsql(sql);
}
@Override
public boolean update(Position entity) {
String sql = "UPDATE position SET isUsing=? , isServing=?,start_time=?,type=?,toiletid=? "
"WHERE id=?";
try (Connection connection = ds.getConnection();
PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setBoolean(1, entity.isUsing());
ps.setBoolean(2, entity.isServing());
ps.setTimestamp(3, new Timestamp(TimeUtils.stringToMiles(entity.getStart_time())));
ps.setString(4, entity.getType());
ps.setInt(5, entity.getToilet().getId());
ps.setInt(6, entity.getId());
ps.executeUpdate();
return true;
} catch(SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public Position getById(int id) {
String sql = "select * from position where id=" id;
try (Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
return getPositionBySql(rs);
}
}catch (SQLException e) {
e.printStackTrace();
return null;
}
return null;
}
public Position getPositionBySql(ResultSet rs) {
Position position = new Position();
try {
position.setId(rs.getInt("id"));
position.setUsing(rs.getBoolean("isUsing"));
position.setServing(rs.getBoolean("isServing"));
position.setStart_time(TimeUtils.dateToString((java.util.Date)rs.getTimestamp("start_time")));
position.setType(rs.getString("type"));
ToiletDAOImpl toiletDAOImpl = new ToiletDAOImpl();
position.setToilet(toiletDAOImpl.getById(rs.getInt("toiletid")));
return position;
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
@Override
public List<Position> getById(int[] ids) {
// 不做
return null;
}
@Override
public List<Position> getAll() {
String sql = "select * from position";
return getPositionList(sql);
}
public List<Position> getPositionByToilet(int id) {
String sql = "select * from position where toiletid=" id;
return getPositionList(sql);
}
public List<Position> getPositionList(String sql) {
List<Position>positions = new ArrayList<>();
try(Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery()) {
while(rs.next()) {
positions.add(getPositionBySql(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return positions;
}
@Override
public void setUsing(boolean isUsing, int id) {
String sql = "UPDATE position SET isUsing=?,start_time=?,WHERE id = ?";
Timestamp date = new Timestamp(System.currentTimeMillis());
try (Connection connection = ds.getConnection();
PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setBoolean(1,isUsing);
ps.setInt(2, id);
ps.setTimestamp(3,date);
ps.executeUpdate();
} catch(SQLException e) {
e.printStackTrace();
}
}