Compare commits

...

49 Commits

Author SHA1 Message Date
pn38qy6fk 1f5f38ea58 Merge pull request '请求合并' (#11) from yinrenhui_branch into master
2 years ago
阴仁辉 45d7fb627e 实践报告提交
2 years ago
pn38qy6fk 074cb79eff Merge pull request '请求合并' (#8) from yinrenhui_branch into master
2 years ago
ysh 511b4886a7 Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/yangshihao_Git
2 years ago
ysh 4bd8f512dc 添加评价报告
2 years ago
pn38qy6fk 9264178653 Merge pull request '请求合并' (#10) from lihaoxiang_branch into master
2 years ago
李浩翔 c9a4afc78d 提交
2 years ago
pn38qy6fk b3026ac400 Merge pull request '合并' (#9) from liaoqixing_branch into master
2 years ago
ysh f0f5cfc3c1 修改
2 years ago
廖启兴 d2aefd8698 提交
2 years ago
ysh 68f3dfdfad Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/yangshihao_Git
2 years ago
ysh f520f3a0d9 系统演示
2 years ago
阴仁辉 72e9582a24 提交
2 years ago
pn38qy6fk 3239c3743f Merge pull request '请求合并' (#4) from yinrenhui_branch into master
2 years ago
阴仁辉 543b683e2e 添加
2 years ago
pn38qy6fk b890fcecec Merge pull request 'xzy' (#7) from xiazeyu_branch into master
2 years ago
ysh ea9568be1c 预警界面
2 years ago
夏泽宇 118a0b00f3 顺序图,报告
2 years ago
夏泽宇 d3da79e46a Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/watermonitor_GIt into xiazeyu_branch
2 years ago
ysh bfeea7ea53 Merge remote-tracking branch 'origin/yijunchi_branch'
2 years ago
ysh 9944f93c1a Merge remote-tracking branch 'remotes/origin/yijunchi_branch'
2 years ago
ysh 6e69a78f69 删除多余
2 years ago
ysh d57023a823 文档上传
2 years ago
夏泽宇 bf543381db 前端1
2 years ago
夏泽宇 2d52b83d35 删除
2 years ago
ysh b001789bf4 Merge remote-tracking branch 'remotes/origin/yinrenhui_branch'
2 years ago
ysh 22d1052532 Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/yangshihao_Git
2 years ago
ysh 750f45cac6 删除
2 years ago
阴仁辉 f09cd12c75 Merge branch 'yinrenhui_branch' of https://bdgit.educoder.net/pn38qy6fk/watermonitor_GIt into yinrenhui_branch
2 years ago
阴仁辉 031c4066a6 修改提交
2 years ago
阴仁辉 061446e38b 修改提交
2 years ago
阴仁辉 d976c10188 修改后提交
2 years ago
夏泽宇 e8efb82da5 前端1
2 years ago
夏泽宇 855833f01c Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/watermonitor_GIt into xiazeyu_branch
2 years ago
阴仁辉 d99d9fa617 提交
2 years ago
pn38qy6fk 89535c8a7c Update README.md
2 years ago
ysh 11662b7742 部分模型
2 years ago
ysh 0a8917303b 提交代码
2 years ago
ysh 45ee709282 Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/yangshihao_Git
2 years ago
ysh 34ad6c7f6b 提交文档
2 years ago
pn38qy6fk 7ce9c47abf Update README.md
2 years ago
ysh 284742afe3 123.txt
2 years ago
ysh e80b8409bf 123
2 years ago
ysh 56a2fd8a01 1
2 years ago
ysh b6e1c079f6 删除
2 years ago
阴仁辉 4cdbed19af 123
2 years ago
夏泽宇 a70143fc9e Merge branch 'master' of https://bdgit.educoder.net/pn38qy6fk/yangshihao_Git into xiazeyu_branch
2 years ago
夏泽宇 617c0267a2 111.txt
2 years ago
夏泽宇 761cb67a5d 111.txt
2 years ago

@ -1,2 +0,0 @@
111
123

@ -1,2 +0,0 @@
# yangshihao_Git

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,20 @@
系统介绍:
1项目意义
软件项目的背景及主要功能:
随着社会的发展和人们对生活健康的关注,加上水资源的日益短缺和恶化,水量水质监测系统的运用备受关注。在对水资源进行管理和保护时,希望能尽快获取到水质水量信息。但是限于时空限制,存在获取信息速度慢、操作复杂、无法确定污染点确切位置的缺陷。或仅对数据进行提供,无法做到可视化直观分析,不能第一时间获取具体信息可能导致不能对即将发生的危害进行及时的预防以至于对社会以及群众造成健康和财产上的损伤。以往采用的水质水量监测方法明显已经远不能满足工作发展的需求。因此发展水质水量在线监测系统势在必行。
本软件专为解决水质水量监测的时效性问题而设计,它可以帮助相关人员实时检测北京、天津各站点的水质水量信息,对相关信息进行监测和相应的数据分析,在监测数据达到异常值时,相关人员将可通过系统明显得知污染站点的水质情况进而通知相关部门开展工作,对可能出现或已经出现的危害进行及时预防或处理。
2软件目标用户
水质水量检测软件是以对北京、天津内各站点的水质水量信息进行实时监测为主题,面向用户主要为环境监测部门与管理部门。环境监测部门可以监测水质水量信息并在获取污染情况信息后通知管理部门;管理部门可以根据相关信息对污染进行预防和处理。
项目特色
1在信息呈现界面相较与同类型的大部分项目做了地图化可视界面同时每个站点的颜色代表不同水质状态使每个站点监测到什么形式数据显得更加清晰合理。
2对站点监测数据做了图表诸如饼图折线图形式的数据分析使数据变化显得简明易懂。
3做了预警界面能够同时将近两天异常站点的数据统计出来并将异常站点呈现在地图上。
4用熵权分析对历史污染事件进行相似分析使用户能够快速找到想要的应急措施。
5使用户能自定义污染区域使得预防显得快速可靠。
# - 运行环境要求windows 10/11,Tomcat 9.0.68,JDK 1.8
- 开发语言JavaJavaScript
- 标准规范Java编码风格规范
- 开发工具IntelliJ IDEA 2021.3.3

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 9.0.27" level="application_server_libraries" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="library" name="jsoup-1.11.2" level="project" />
<orderEntry type="library" name="fastjson-1.2.47" level="project" />
<orderEntry type="library" name="commons-fileupload-1.3.1" level="project" />
</component>
</module>

@ -0,0 +1,14 @@
package dao;
import domain.Example;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-05 13:39
*/
public interface ExampleDao
{
public abstract List<Example> findResembleExamples();
}

@ -0,0 +1,20 @@
package dao;
import domain.PageBean;
import domain.WaterLevel;
import java.util.List;
import java.util.Map;
public interface WaterLevelDao
{
public abstract List<WaterLevel> findAllByPage(int start,int pageSize);//从start开始查询pagesize行信息
public abstract int findAllCount();//查询水位信息的总量
public abstract boolean addWaterLevelInfo(WaterLevel waterLevel);
public abstract boolean update(WaterLevel waterLevel);
public abstract boolean deleteInfo(int id);
public abstract List<WaterLevel> conditionalQueryByPage(int start, int pageSize, Map<String,String[]> condition);//条件查找
public abstract int conditionalFindAllCount(Map<String, String[]> condition);//条件查找总数
public abstract List<WaterLevel> findBySiteName(String siteName);//通过站点来查询水位信息,查询一个站点的所有水位信息
public abstract List<WaterLevel> findWeekData();//返回过去一周的数据,及筛出时间戳在一周以内的数据
}

@ -0,0 +1,26 @@
package dao;
import domain.StationAndQuality;
import domain.Statistics;
import domain.WaterQuality;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-20 15:03
*/
public interface WaterQualityDao
{
public abstract boolean add(WaterQuality waterQuality);//添加一条记录
public abstract List<WaterQuality> findByName(String stationName);
public abstract boolean update(WaterQuality waterQuality);
public abstract boolean del(int id);
public abstract WaterQuality findNewestRecord(String stationName);
public abstract List<WaterQuality> findPollutedWater();
public abstract List<WaterQuality> findByNameAndTime(String name,String startTime,String endTime,String level);
public abstract List<WaterQuality> findByStationName(String name);
public abstract List<WaterQuality> findWeekData();
}

@ -0,0 +1,30 @@
package dao.impl;
import dao.ExampleDao;
import domain.Example;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import util.JDBCUtils;
import java.util.List;
public class ExampleDaoImpl implements ExampleDao
{
JdbcTemplate template=new JdbcTemplate(JDBCUtils.getDataSource());
@Override
public List<Example> findResembleExamples()
{
List<Example> query = null;
try {
String sql="select * from example";
query = template.query(sql, new BeanPropertyRowMapper<Example>(Example.class));
} catch (Exception e) {
System.out.println(e);
}
return query;
}
}

@ -0,0 +1,252 @@
package dao.impl;
//Java DataBase Connectivity Java 数据库连接, Java语言操作数据库
import dao.WaterLevelDao;
import domain.PageBean; //分页对象
import domain.WaterLevel; //水位信息对象
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
//BeanPropertyRowMapper 是 RowMapper 执行该表的行转换成指定的映射的目标类的一个新实例
import org.springframework.jdbc.core.JdbcTemplate;
//JdbcTemplate 是 Spring JDBC 核心包core中的核心类
// 它可以通过配置文件、注解、Java 配置类等形式获取数据库的相关信息,
// 实现了对 JDBC 开发过程中的驱动加载、连接的开启和关闭、SQL 语句的创建与执行、异常处理、事务处理、数据类型转换等操作的封装。
// 我们只要对其传入SQL 语句和必要的参数即可轻松进行 JDBC 编程
import util.JDBCUtils;
//JDBCUtils的作用连接数据库的四大参数是驱动类、URL、用户名、密码
// 这些参数都是与特定数据库关联,如果将来想要更改数据库,那么就要去修改这四大参数,那么为了不去修改代码,
// 我们需要写一个JDBCUtils类让它从配置文件中读取到配置参数然后创建连接对象
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class WaterLevelDaoImpl implements WaterLevelDao
{
JdbcTemplate template=new JdbcTemplate(JDBCUtils.getDataSource());
@Override
public List<WaterLevel> findAllByPage(int start,int pageSize)//查询从start行数为pageSize的水位数据
{
String sql="select * from water_level limit ?,?";
List<WaterLevel> list = template.query(sql, new BeanPropertyRowMapper<WaterLevel>(WaterLevel.class),start,pageSize);
//获取水位信息start开始
return list;//返回从第start开始的水位信息的列表所查询信息的行数为pageSize
}
@Override
public int findAllCount()//返回水位信息数据总数
{
String sql="select count(*) from water_level";
int integer = template.queryForObject(sql, Integer.class);
return integer;
}
@Override
public boolean addWaterLevelInfo(WaterLevel waterLevel)//添加水位信息
{
String sq="select * from water_level where siteName=? and collectionDate=?";
List<WaterLevel> query=null;
try {
query = template.query(sq, new BeanPropertyRowMapper<WaterLevel>(WaterLevel.class), waterLevel.getSiteName(), waterLevel.getCollectionDate());
} catch (Exception e) {
System.out.println(e);
}
int update=0;
if(query==null||query.size()==0)//没有查询到该水位信息信息,则添加该信息
{
try {
String sql="insert into water_level (id,riverName,siteName,collectionDate,waterLevel,flow,over) values(null,?,?,?,?,?,?)";
update = template.update(sql, waterLevel.getRiverName(),
waterLevel.getSiteName(),
waterLevel.getCollectionDate(),
waterLevel.getWaterLevel(),
waterLevel.getFlow(),
waterLevel.getOver());
} catch (Exception e) {
System.out.println(e);
}
}
if(update!=0)//含有该信息则不添加该水位信息
{
return true;
}
else
{
return false;
}
}
@Override
public boolean update(WaterLevel waterLevel)//修改水位信息
{
int update=0;
try {
String sql="update water_level set riverName=?,siteName=?,collectionDate=? ,waterLevel=?,flow=?,over=? where id=?";
update = template.update(sql,
waterLevel.getRiverName(),
waterLevel.getSiteName(),
waterLevel.getCollectionDate(),
waterLevel.getWaterLevel(),
waterLevel.getFlow(),
waterLevel.getOver(),
waterLevel.getId());
} catch (DataAccessException e) {
e.printStackTrace();
}
if(update!=0)
{
return true;
}
else
{
return false;
}
}
@Override
public boolean deleteInfo(int id)//根据id来删除相关水位信息
{
int update=0;
try {
String sql="delete from water_level where id=?";
update = template.update(sql, id);
} catch (DataAccessException e) {
e.printStackTrace();
}
if(update!=0)
{
return true;
}
else
{
return false;
}
}
@Override
public List<WaterLevel> conditionalQueryByPage(int start, int pageSize, Map<String,String[]> condition)//条件查询
//map为映射condition为该映射的名
{
StringBuilder builder=new StringBuilder();//代表整个sql语句
String starStr="select * from water_level where 1=1 ";
builder.append(starStr);
List<Object> valueList=new ArrayList<>();
//遍历map集合
for(String key:condition.keySet())
{
//排除分页条件参数
if("currentPage2".equals(key) || "pageSize2".equals(key))
{
continue;
}
String value = condition.get(key)[0];
if(value!=null&&!"".equals(value))
{
builder.append(" and "+key+" like ? ");
valueList.add("%"+value+"%");
}
}
builder.append(" limit ?,? ");
//sql = select * from water_level where 1=1 " and "+key+" like ? " limit ?,?
valueList.add(start);
valueList.add(pageSize);
String sql = builder.toString();
System.out.println(sql);//sql语句
System.out.println(Arrays.toString(valueList.toArray()));//查询条件
//执行sql条件查询
List<WaterLevel> objList = null;
try {
objList = template.query(sql, new BeanPropertyRowMapper<WaterLevel>(WaterLevel.class), valueList.toArray());
} catch (Exception e) {
System.out.println(e);
}
return objList;//返回条件查询结果
}
@Override
public int conditionalFindAllCount(Map<String, String[]> condition)//条件查询的总记录数,符合条件的总数
{
StringBuilder builder=new StringBuilder();//代表整个sql语句
String starStr="select count(*) from water_level where 1=1 ";
builder.append(starStr);
List<Object> valueList=new ArrayList<>();
//遍历map集合
for(String key:condition.keySet())
{
//排除分页条件参数
if("currentPage2".equals(key) || "pageSize2".equals(key))
{
continue;
}
String value = condition.get(key)[0];
if(value!=null&&!"".equals(value))
{
builder.append(" and "+key+" like ? ");
valueList.add("%"+value+"%");
}
}
String sql = builder.toString();
System.out.println(sql);
System.out.println(valueList);
int integer = 0;
try {
integer = template.queryForObject(sql, Integer.class, valueList.toArray());
} catch (Exception e) {
System.out.println(e);
}
return integer;
}
@Override
public List<WaterLevel> findBySiteName(String siteName)//通过站点来查询水位信息,插叙一个站点的所有水位信息
{
List<WaterLevel> query = null;
try {
String sql="SELECT * FROM water_level WHERE siteName=? ORDER BY collectionDate";
query = template.query(sql, new BeanPropertyRowMapper<WaterLevel>(WaterLevel.class), siteName);
} catch (Exception e) {
System.out.println(e);
}
return query;
}
@Override
public List<WaterLevel> findWeekData()//返回过去一周的数据,及筛出时间戳在一种以内的数据
{
List<WaterLevel> query = null;
try {
String sql="SELECT * FROM water_level WHERE TO_DAYS(NOW())-TO_DAYS(collectionDate)<=6 ORDER BY collectionDate DESC;";
query = template.query(sql, new BeanPropertyRowMapper<WaterLevel>(WaterLevel.class));
} catch (Exception e) {
System.out.println(e);
}
return query;
}
}

@ -0,0 +1,203 @@
package dao.impl;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import dao.WaterQualityDao;
import domain.StationAndQuality;
import domain.Statistics;//水质信息对象和水质的站点信息对象
import domain.WaterQuality;//统计对象
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import util.JDBCUtils;
import java.sql.Timestamp;
import java.util.LinkedList;
import java.util.List;
public class WaterQualityDaoImpl implements WaterQualityDao
{
private JdbcTemplate template=new JdbcTemplate(JDBCUtils.getDataSource());
@Override
public boolean add(WaterQuality waterQuality)//添加水质信息
{
String sq="select * from water_quality where belongStation=? and datetime =?";
List<WaterQuality> query=null;
try {
query = template.query(sq, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class),waterQuality.getBelongStation(),waterQuality.getDateTime());
} catch (Exception e) {
System.out.println(e);
}
System.out.println(query);
int update=0;
if(query==null||query.size()==0)//如果数据不存在,才允许插入数据,保证数据的唯一性
{
try {
String sql="insert into water_quality (belongStation,dateTime,pH,DO,NH4,CODMn,TOC,level) values (?,?,?,?,?,?,?,?)";
update = template.update(sql, waterQuality.getBelongStation(),
waterQuality.getDateTime(), waterQuality.getpH(), waterQuality.getdO(), waterQuality.getnH4(),
waterQuality.getcODMn(), waterQuality.gettOC(), waterQuality.getLevel());
} catch (Exception e) {
System.out.println(e);
}
}
if(update==0)
{
return false;
}
else
{
return true;
}
}
@Override
public List<WaterQuality> findByName(String stationName)//通过水质信息所属站点名来查询水质信息
{
List<WaterQuality> list=null;
try
{
String sql="select * from water_quality where belongStation=?";
list = template.query(sql, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class), stationName);
} catch (Exception e)
{
System.out.println(e);
}
return list;
}
@Override
public boolean update(WaterQuality waterQuality)//更新水质信息
{
int update=0;
try
{
String sql="update water_quality set belongStation=?,dateTime=?,pH=?,DO=?,NH4=?,CODMn=?,TOC=?,level=? where id=?";
update = template.update(sql, waterQuality.getBelongStation(),
waterQuality.getDateTime(), waterQuality.getpH(), waterQuality.getdO(), waterQuality.getnH4(),
waterQuality.getcODMn(), waterQuality.gettOC(), waterQuality.getLevel(), waterQuality.getId());
} catch (Exception e)
{
System.out.println(e);
}
return update!=0;
}
@Override
public boolean del(int id)//通过id删除水质信息
{
int update=0;
try
{
String sql="delete from water_quality where id=?";
update = template.update(sql, id);
} catch (Exception e)
{
System.out.println(e);
}
return update!=0;
}
@Override
public WaterQuality findNewestRecord(String stationName)//返回某站点最新的水质信息
{
WaterQuality waterQuality = null;
try
{
String sql="SELECT * FROM water_quality WHERE belongStation=? ORDER BY DATETIME DESC LIMIT 1";
waterQuality = template.queryForObject(sql, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class),stationName);
} catch (Exception e)
{
System.out.println(e);
}
return waterQuality;
}
@Override
public List<WaterQuality> findPollutedWater()//查询到有污染的水质信息
{
List<WaterQuality> list=null;
try {
String sql="SELECT * FROM water_quality WHERE \n" +
"(LEVEL='Ⅳ' OR LEVEL='' OR LEVEL='劣Ⅴ') AND TO_DAYS(NOW())- TO_DAYS(DATETIME)<= 1 ORDER BY DATETIME DESC ";
list = template.query(sql, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class));
} catch (Exception e) {
System.out.println(e);
}
return list;
}
@Override
public List<WaterQuality> findByNameAndTime(String name, String startTime, String endTime,String level)
//通过站点名以及某一时间段以及污染级别来查询水质信息
{
StringBuilder stringBuilder=new StringBuilder("SELECT * FROM water_quality WHERE 1=1 ");
LinkedList<String> list=new LinkedList<>();
if(name!=null&&!name.equals(""))
{
stringBuilder.append(" AND belongStation LIKE ? ");
list.add("%"+name+"%");
}
if(startTime!=null&&!startTime.equals("")&&!startTime.equals(":00"))
{
stringBuilder.append(" AND DATETIME >=? ");
list.add(startTime);
}
if(endTime!=null&&!endTime.equals("")&&!endTime.equals(":00"))
{
stringBuilder.append(" AND DATETIME <=? ");
list.add(endTime);
}
if(level!=null&&!level.equals("")&&!level.equals("--水质类别--"))
{
stringBuilder.append(" AND level =? ");
list.add(level);
}
stringBuilder.append(" ORDER BY DATETIME DESC ");
String sql=stringBuilder.toString();
System.out.println(sql);
Object[] objects =list.toArray();
List<WaterQuality> query = null;
try {
query = template.query(sql, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class), objects);
} catch (Exception e) {
System.out.println(e);
}
return query;
}
@Override
public List<WaterQuality> findByStationName(String name)//通过水质所属站点查询水质信息,并通过时间排序
{
List<WaterQuality> query = null;
try {
String sql="SELECT * FROM water_quality WHERE belongStation=? ORDER BY DATETIME";
query = template.query(sql, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class), name);
} catch (Exception e) {
System.out.println(e);
}
return query;
}
@Override
public List<WaterQuality> findWeekData()//查询最近一周的水质信息
{
List<WaterQuality> query = null;
try {
String sql="SELECT * FROM water_quality WHERE TO_DAYS(NOW())-TO_DAYS(DATETIME)<=6 ORDER BY DATETIME DESC";
query = template.query(sql, new BeanPropertyRowMapper<WaterQuality>(WaterQuality.class));
} catch (Exception e) {
System.out.println(e);
}
return query;
}
}

@ -0,0 +1,153 @@
package domain;
/**
* @author laoyingyong
* @date: 2020-02-05 13:28
*/
public class Example implements Comparable<Example>
{
private Integer id;
private String name;
private String type;
private String source;
private Double multiple;
private Integer distance;
private String toxicity;
private String danger;
private String stability;
private String solubility;
private String volatility;
private String technology;
private Double sim;
public Double getSim() {
return sim;
}
public void setSim(Double sim) {
this.sim = sim;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public Double getMultiple() {
return multiple;
}
public void setMultiple(Double multiple) {
this.multiple = multiple;
}
public Integer getDistance() {
return distance;
}
public void setDistance(Integer distance) {
this.distance = distance;
}
public String getToxicity() {
return toxicity;
}
public void setToxicity(String toxicity) {
this.toxicity = toxicity;
}
public String getDanger() {
return danger;
}
public void setDanger(String danger) {
this.danger = danger;
}
public String getStability() {
return stability;
}
public void setStability(String stability) {
this.stability = stability;
}
public String getSolubility() {
return solubility;
}
public void setSolubility(String solubility) {
this.solubility = solubility;
}
public String getVolatility() {
return volatility;
}
public void setVolatility(String volatility) {
this.volatility = volatility;
}
public String getTechnology() {
return technology;
}
public void setTechnology(String technology) {
this.technology = technology;
}
@Override
public String toString() {
return "Example{" +
"id=" + id +
", name='" + name + '\'' +
", type='" + type + '\'' +
", source='" + source + '\'' +
", multiple=" + multiple +
", distance=" + distance +
", toxicity='" + toxicity + '\'' +
", danger='" + danger + '\'' +
", stability='" + stability + '\'' +
", solubility='" + solubility + '\'' +
", volatility='" + volatility + '\'' +
", technology='" + technology + '\'' +
", sim=" + sim +
'}';
}
@Override
public int compareTo(Example example)
{
return this.sim<example.sim?1:this.sim>example.sim?-1:0;
}
}

@ -0,0 +1,22 @@
package domain;
public class ResultInfo
{
private String msg;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public String toString() {
return "ResultInfo{" +
"msg='" + msg + '\'' +
'}';
}
}

@ -0,0 +1,35 @@
package domain;
/**
* @author laoyingyong
* @date: 2020-02-03 16:55
*/
public class StationAndQuality
{
private WaterQualityStation station;
private WaterQuality quality;
public WaterQualityStation getStation() {
return station;
}
public void setStation(WaterQualityStation station) {
this.station = station;
}
public WaterQuality getQuality() {
return quality;
}
public void setQuality(WaterQuality quality) {
this.quality = quality;
}
@Override
public String toString() {
return "StationAndQuality{" +
"station=" + station +
", quality=" + quality +
'}';
}
}

@ -0,0 +1,85 @@
package domain;
/**
* @author laoyingyong
* @date: 2020-01-30 12:47
*/
public class Statistics
{
private int a;//I类水质的数量
private int b;//II类水质的数量
private int c;//III类水质的数量
private int d;//IV类水质的数量
private int e;//V类水质的数量
private int f;//劣V类水质的数量
private int g;//其他
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public int getB() {
return b;
}
public void setB(int b) {
this.b = b;
}
public int getC() {
return c;
}
public void setC(int c) {
this.c = c;
}
public int getD() {
return d;
}
public void setD(int d) {
this.d = d;
}
public int getE() {
return e;
}
public void setE(int e) {
this.e = e;
}
public int getF() {
return f;
}
public void setF(int f) {
this.f = f;
}
public int getG() {
return g;
}
public void setG(int g) {
this.g = g;
}
@Override
public String toString() {
return "Statistics{" +
"a=" + a +
", b=" + b +
", c=" + c +
", d=" + d +
", e=" + e +
", f=" + f +
", g=" + g +
'}';
}
}

@ -0,0 +1,102 @@
package domain;
public class User
{
private int id;
private String name;
private String gender;
private int age;
private String address;
private String qq;
private String email;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
", gender='" + gender + '\'' +
", age=" + age +
", address='" + address + '\'' +
", qq='" + qq + '\'' +
", email='" + email + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
'}';
}
}

@ -0,0 +1,84 @@
package domain;
import java.sql.Timestamp;
public class WaterLevel
{
private Integer id;
private String riverName;
private String siteName;
private Timestamp collectionDate;
private Double waterLevel;
private Double flow;
private Double over;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getRiverName() {
return riverName;
}
public void setRiverName(String riverName) {
this.riverName = riverName;
}
public String getSiteName() {
return siteName;
}
public void setSiteName(String siteName) {
this.siteName = siteName;
}
public Timestamp getCollectionDate() {
return collectionDate;
}
public void setCollectionDate(Timestamp collectionDate) {
this.collectionDate = collectionDate;
}
public Double getWaterLevel() {
return waterLevel;
}
public void setWaterLevel(Double waterLevel) {
this.waterLevel = waterLevel;
}
public Double getFlow() {
return flow;
}
public void setFlow(Double flow) {
this.flow = flow;
}
public Double getOver() {
return over;
}
public void setOver(Double over) {
this.over = over;
}
@Override
public String toString() {
return "WaterLevel{" +
"id=" + id +
", riverName='" + riverName + '\'' +
", siteName='" + siteName + '\'' +
", collectionDate=" + collectionDate +
", waterLevel=" + waterLevel +
", flow=" + flow +
", over=" + over +
'}';
}
}

@ -0,0 +1,107 @@
package domain;
import java.sql.Timestamp;
/**
* @author laoyingyong
* @date: 2020-01-19 15:24
*/
public class WaterQuality
{
private Integer id;
private String belongStation;
private Timestamp dateTime;
private Double pH;
private Double dO;
private Double nH4;
private Double cODMn;
private Double tOC;
private String level;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getBelongStation() {
return belongStation;
}
public void setBelongStation(String belongStation) {
this.belongStation = belongStation;
}
public Timestamp getDateTime() {
return dateTime;
}
public void setDateTime(Timestamp dateTime) {
this.dateTime = dateTime;
}
public Double getpH() {
return pH;
}
public void setpH(Double pH) {
this.pH = pH;
}
public Double getdO() {
return dO;
}
public void setdO(Double dO) {
this.dO = dO;
}
public Double getnH4() {
return nH4;
}
public void setnH4(Double nH4) {
this.nH4 = nH4;
}
public Double getcODMn() {
return cODMn;
}
public void setcODMn(Double cODMn) {
this.cODMn = cODMn;
}
public Double gettOC() {
return tOC;
}
public void settOC(Double tOC) {
this.tOC = tOC;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
@Override
public String toString() {
return "WaterQuality{" +
"id=" + id +
", belongStation='" + belongStation + '\'' +
", dateTime=" + dateTime +
", pH=" + pH +
", dO=" + dO +
", nH4=" + nH4 +
", cODMn=" + cODMn +
", tOC=" + tOC +
", level='" + level + '\'' +
'}';
}
}

@ -0,0 +1,72 @@
package domain;
public class WaterQualityStation
{
private int id;
private String stationName;
private Double longitude;
private Double latitude;
private String section;
private String introduction;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getStationName() {
return stationName;
}
public void setStationName(String stationName) {
this.stationName = stationName;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
@Override
public String toString() {
return "WaterQualityStation{" +
"id=" + id +
", stationName='" + stationName + '\'' +
", longitude=" + longitude +
", latitude=" + latitude +
", section='" + section + '\'' +
", introduction='" + introduction + '\'' +
'}';
}
}

@ -0,0 +1,10 @@
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/river?characterEncoding=utf8
username=root
password=root
# 初始化连接数量
initialSize=5
# 最大连接数
maxActive=10
# 最大等待时间
maxWait=3000

@ -0,0 +1,16 @@
package service;
import domain.Example;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-05 13:47
*/
public interface ExampleService
{
public abstract List<Example> findResembleExamples(
String type,String source,double multiple,
int distance,String toxicity,String danger,String stability,String solubility,String volatility);
}

@ -0,0 +1,22 @@
package service;
import domain.PageBean;//分页对象
import domain.WaterLevel;
import java.util.List;
import java.util.Map;
public interface WaterLevelService
{
public abstract PageBean<WaterLevel> findAllByPage(int currentPage,int pageSize);
public abstract int findAllCount();
public abstract boolean addWaterLevelInfo(WaterLevel waterLevel);
public abstract int addManyLevel(List<WaterLevel> levelList);
public abstract boolean update(WaterLevel waterLevel);
public abstract boolean deleteInfo(int id);
public abstract PageBean<WaterLevel> conditionalQueryByPage(int currentPage,int pageSize, Map<String, String[]> condition);
public abstract int conditionalFindAllCount(Map<String, String[]> condition);
public abstract List<WaterLevel> findBySiteName(String siteName);
public abstract List<WaterLevel> findWeekData();
}

@ -0,0 +1,30 @@
package service;
import dao.WaterQualityDao;
import dao.impl.WaterQualityDaoImpl;
import domain.Statistics;
import domain.WaterQuality;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-20 15:15
*/
public interface WaterQualityService
{
public abstract int add(List<WaterQuality> waterQualityList);
public abstract boolean addOne(WaterQuality waterQuality);
public abstract List<WaterQuality> findByName(String stationName);
public abstract boolean update(WaterQuality waterQuality);
public abstract boolean del(int id);
public abstract Statistics count(String stationName);
public abstract WaterQuality findNewestRecord(String stationName);
public abstract List<WaterQuality> findPollutedWater();
public abstract List<WaterQuality> findByNameAndTime(String name,String startTime,String endTime,String level);
public abstract List<WaterQuality> findByStationName(String name);
public abstract List<WaterQuality> findWeekData();
}

@ -0,0 +1,103 @@
package service.impl;
import dao.ExampleDao;
import dao.impl.ExampleDaoImpl;
import domain.Example;
import service.ExampleService;
import util.ExampleUtils;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-05 13:47
*/
public class ExampleServiceImpl implements ExampleService
{
ExampleDao dao=new ExampleDaoImpl();
@Override
public List<Example> findResembleExamples(String type, String source, double multiple, int distance, String toxicity, String danger, String stability, String solubility, String volatility)
{
double [] current=new double[9];//当前污染事件的数组
//给数组赋值
current[0]=1;
current[1]=1;
current[2]= ExampleUtils.getMultipleNum(multiple);//超标倍数
current[3]=ExampleUtils.getDistanceNum(distance);
current[4]=ExampleUtils.getToxicityNum(toxicity);
current[5]=ExampleUtils.getDangerNum(danger);
current[6]=ExampleUtils.getStabilityNum(stability);
current[7]=ExampleUtils.getSolubilityNum(solubility);
current[8]=ExampleUtils.getVolatilityNum(volatility);
List<Example> list = dao.findResembleExamples();
LinkedList<Example> exampleLinkedList=new LinkedList<>();
for (Example example : list)
{
String type1 = example.getType();
String source1 = example.getSource();
Double multiple1 = example.getMultiple();
Integer distance1 = example.getDistance();
String toxicity1 = example.getToxicity();
String danger1 = example.getDanger();
String stability1 = example.getStability();
String solubility1 = example.getSolubility();
String volatility1 = example.getVolatility();
double [] history=new double[9];//历史污染事件的数组
//给数组赋值
if(type1.equals(type))//如果污染物类型相同就赋值为1否则为0
{
history[0]=1;
}
else
{
history[0]=0;
}
if(source1.equals(source))//如果污染物来源相同就赋值为1否则赋值为0
{
history[1]=1;
}
else
{
history[1]=0;
}
history[2]= ExampleUtils.getMultipleNum(multiple1);//超标倍数
history[3]=ExampleUtils.getDistanceNum(distance1);//距离
history[4]=ExampleUtils.getToxicityNum(toxicity1);//毒性
history[5]=ExampleUtils.getDangerNum(danger1);//危险程度
history[6]=ExampleUtils.getStabilityNum(stability1);//稳定性
history[7]=ExampleUtils.getSolubilityNum(solubility1);//溶解性
history[8]=ExampleUtils.getVolatilityNum(volatility1);//挥发性
double sim=(1-Math.abs(current[0]-history[0]))*0.1123+//根据熵权G1法计算当前污染事件与历史污染事件的相似度
(1-Math.abs(current[1]-history[1]))*0.1123+
(1-Math.abs(current[2]-history[2]))*0.1123+
(1-Math.abs(current[3]-history[3]))*0.1123+
(1-Math.abs(current[4]-history[4]))*0.1112+
(1-Math.abs(current[5]-history[5]))*0.1112+
(1-Math.abs(current[6]-history[6]))*0.1109+
(1-Math.abs(current[7]-history[7]))*0.1088+
(1-Math.abs(current[8]-history[8]))*0.1088;
DecimalFormat decimalFormat=new DecimalFormat("0.0000");//保留四位小数
String format = decimalFormat.format(sim);
double v = Double.parseDouble(format);
example.setSim(v);//设置相似度
if(v>0.7)//如果相似度大于0.7的话,就存入集合中
{
exampleLinkedList.add(example);
}
}
Collections.sort(exampleLinkedList);//按照相似度从大到小排序Example这个实体类要实现Comparable接口才行
System.out.println("排序后"+exampleLinkedList);
return exampleLinkedList;
}
}

@ -0,0 +1,107 @@
package service.impl;
import dao.WaterLevelDao;
import dao.impl.WaterLevelDaoImpl;
import domain.PageBean;
import domain.WaterLevel;
import service.WaterLevelService;
import java.util.List;
import java.util.Map;
public class WaterLevelServiceImpl implements WaterLevelService
{
WaterLevelDao dao=new WaterLevelDaoImpl();
@Override
public PageBean<WaterLevel> findAllByPage(int currentPage,int pageSize)
{
PageBean<WaterLevel> pageBean=new PageBean<>();
pageBean.setCurrentPage(currentPage);
pageBean.setRows(pageSize);
int totalCount = dao.findAllCount();
pageBean.setTotalCount(totalCount);
int start=(currentPage-1)*pageSize;
List<WaterLevel> allByPage = dao.findAllByPage(start, pageSize);
pageBean.setList(allByPage);
int totalPage=totalCount%pageSize==0?totalCount/pageSize:(totalCount/pageSize+1);
pageBean.setTotalPage(totalPage);
return pageBean;
}
@Override
public int findAllCount()
{
return dao.findAllCount();
}
@Override
public boolean addWaterLevelInfo(WaterLevel waterLevel)
{
boolean b = dao.addWaterLevelInfo(waterLevel);
return b;
}
@Override
public int addManyLevel(List<WaterLevel> levelList)
{
int count=0;
for (WaterLevel waterLevel : levelList)
{
boolean b = dao.addWaterLevelInfo(waterLevel);
if (b)
{
count++;
}
}
return count;
}
@Override
public boolean update(WaterLevel waterLevel)
{
boolean update = dao.update(waterLevel);
return update;
}
@Override
public boolean deleteInfo(int id)
{
boolean b = dao.deleteInfo(id);
return b;
}
@Override
public PageBean<WaterLevel> conditionalQueryByPage(int currentPage, int pageSize, Map<String, String[]> condition)
{
PageBean<WaterLevel> pageBean=new PageBean<>();
int totalCount= dao.conditionalFindAllCount(condition);
pageBean.setTotalCount(totalCount);
int totalPage=totalCount%pageSize==0?totalCount/pageSize:(totalCount/pageSize+1);
pageBean.setTotalPage(totalPage);
pageBean.setCurrentPage(currentPage);
pageBean.setRows(pageSize);
List<WaterLevel> list = dao.conditionalQueryByPage((currentPage - 1) * pageSize, pageSize, condition);
pageBean.setList(list);
return pageBean;
}
@Override
public int conditionalFindAllCount(Map<String, String[]> condition)
{
int i = dao.conditionalFindAllCount(condition);
return i;
}
@Override
public List<WaterLevel> findBySiteName(String siteName) {
return dao.findBySiteName(siteName);
}
@Override
public List<WaterLevel> findWeekData() {
return dao.findWeekData();
}
}

@ -0,0 +1,146 @@
package service.impl;
import dao.WaterQualityDao;
import dao.impl.WaterQualityDaoImpl;
import domain.Statistics;
import domain.WaterQuality;
import service.WaterQualityService;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-20 15:18
*/
public class WaterQualityServiceImpl implements WaterQualityService
{
WaterQualityDao dao=new WaterQualityDaoImpl();
@Override
public int add(List<WaterQuality> waterQualityList)
{
int count=0;
for (WaterQuality waterQuality : waterQualityList)
{
boolean flag = dao.add(waterQuality);
if(flag)
{
count++;
}
}
return count;//返回的是添加成功的记录数
}
@Override
public boolean addOne(WaterQuality waterQuality)
{
boolean add = dao.add(waterQuality);
return add;
}
@Override
public List<WaterQuality> findByName(String stationName)
{
List<WaterQuality> list= dao.findByName(stationName);
return list;
}
@Override
public boolean update(WaterQuality waterQuality)
{
return dao.update(waterQuality);
}
@Override
public boolean del(int id)
{
return dao.del(id);
}
@Override
public Statistics count(String stationName)
{
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
int g=0;
List<WaterQuality> list = dao.findByName(stationName);
for (WaterQuality waterQuality : list)
{
String level = waterQuality.getLevel();
if(level.equals(""))
{
a++;
}
else if(level.equals("Ⅱ"))
{
b++;
}
else if(level.equals("Ⅲ"))
{
c++;
}
else if(level.equals("Ⅳ"))
{
d++;
}
else if(level.equals(""))
{
e++;
}
else if(level.equals("劣Ⅴ"))
{
f++;
}
else
{
g++;
}
}
Statistics statistics=new Statistics();
statistics.setA(a);
statistics.setB(b);
statistics.setC(c);
statistics.setD(d);
statistics.setE(e);
statistics.setF(f);
statistics.setG(g);
return statistics;
}
@Override
public WaterQuality findNewestRecord(String stationName)
{
return dao.findNewestRecord(stationName);
}
@Override
public List<WaterQuality> findPollutedWater() {
return dao.findPollutedWater();
}
@Override
public List<WaterQuality> findByNameAndTime(String name, String startTime, String endTime,String level) {
return dao.findByNameAndTime(name,startTime,endTime,level);
}
@Override
public List<WaterQuality> findByStationName(String name)
{
return dao.findByStationName(name);
}
@Override
public List<WaterQuality> findWeekData()
{
return dao.findWeekData();
}
}

@ -0,0 +1,93 @@
package test;
import domain.Example;
import util.JDBCUtils;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
/**
* JDBCUtils
*
*/
public class testJDBCU {
public static void main(String[] args) {
List<Example> example = new testJDBCU().finAll();
System.out.println(example);
System.out.println(example.size());
}
public List<Example> finAll() {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
List<Example> list = null;
try {
//1. 导入驱动jar包 mysql-connector-java-5.1.37-bin.jar
//2. 注册驱动
//以上2步骤都通过JDBCUtils来简化了
connection= JDBCUtils.getConnection();
//3.定义sql
String sql = "SELECT * from Example";
//4.获取执行sql的对象
statement = connection.createStatement();
//5.执行sql
resultSet = statement.executeQuery(sql);
//6.遍历结果集,封装对象,装载集合
Example stu = null;
list = new ArrayList<Example>();
while (resultSet.next()) {
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
String type = resultSet.getString("type");
String source = resultSet.getString("source");
double multiple = resultSet.getDouble("multiple");
int distance = resultSet.getInt("distance");
String toxicity = resultSet.getString("toxicity");
String danger = resultSet.getString("danger");
String stability = resultSet.getString("stability");
String solubility = resultSet.getString("solubility");
String volatility = resultSet.getString("volatility");
String technology = resultSet.getString("technology");
stu = new Example();
stu.setId(id);
stu.setName(name);
stu.setType(type);
stu.setSource(source);
stu.setMultiple(multiple);
stu.setDistance(distance);
stu.setToxicity(toxicity);
stu.setDanger(danger);
stu.setStability(stability);
stu.setSolubility(solubility);
stu.setVolatility(volatility);
stu.setTechnology(technology);
list.add(stu);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return list;
}
}

@ -0,0 +1,151 @@
package test1;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import domain.WaterQuality;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class Demo3
{
private static List<WaterQuality> qualityList;
private static String [] siteArray={"沙窝","清河闸","罗庄","密云水库","后城",
"土门楼","万家码头","海河大闸","蓟运河防潮闸",
"于桥水库库中心","三岔口"};
public static void main(String[] args) throws Exception
{
//参数字符串,如果拼接在请求链接之后,需要对中文进行 URLEncode 字符集 UTF-8
String param = "AreaID=&RiverID=&MNName=&PageIndex=1&PageSize=60&action=getRealDatas";
StringBuilder sb = new StringBuilder();
InputStream is = null;
BufferedReader br = null;
PrintWriter out = null;
try {
//接口地址
String url = "https://szzdjc.cnemc.cn:8070/GJZ/Ajax/Publish.ashx";
URL uri = new URL(url);
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestMethod("POST");
connection.setConnectTimeout(50000);
connection.setReadTimeout(12000);
connection.setRequestProperty("accept", "*/*");
//发送参数
connection.setDoOutput(true);
out = new PrintWriter(connection.getOutputStream());
out.print(param);
out.flush();
//接收结果
is = connection.getInputStream();
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line;
//缓冲逐行读取
while ((line = br.readLine()) != null) {
sb.append(line);
}
String backStr = sb.toString();
String body = backStr;
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine engine = sem.getEngineByExtension("js");
String traseStr = null;
try {
traseStr = (String) engine.eval("unescape('" + body + "')");
} catch (ScriptException e) {
e.printStackTrace();
}
traseStr = traseStr.replaceAll("<br>", "\r\n");
traseStr = traseStr.replaceAll("<.*?>", "");
String a= "["+traseStr+"]";
System.out.println(a);
JSONArray jsonArray = JSONObject.parseArray(a);
JSONObject jsonObject = jsonArray.getJSONObject(0);
String jsonArray0 = jsonObject.getString("tbody");
System.out.println(jsonArray0);
JSONArray jsonArray1 = JSONObject.parseArray(jsonArray0);
qualityList=new LinkedList<>();
for (int i = 0; i < jsonArray1.size(); i++) {
WaterQuality waterQuality=new WaterQuality();
JSONArray jsonArray2 = (JSONArray) jsonArray1.get(i);
String siteName = jsonArray2.getString(2);
boolean b = Arrays.asList(siteArray).contains(siteName);
String dateTime = jsonArray2.getString(3);
String pH = jsonArray2.getString(6);
String aDo = jsonArray2.getString(7);
String nh4 = jsonArray2.getString(11);
String codMn = jsonArray2.getString(10);
String toc = jsonArray2.getString(12);
String level = jsonArray2.getString(4);
if (b) {
System.out.print(siteName + "\t");
System.out.print(dateTime + "\t");
System.out.print(pH + "\t");
System.out.print(aDo + "\t");
System.out.print(nh4 + "\t");
System.out.print(codMn + "\t");
System.out.print(toc + "\t");
System.out.println(level);
waterQuality.setBelongStation(siteName);
waterQuality.setDateTime(Timestamp.valueOf("2022-"+dateTime+":00"));
if(!pH.equals("--"))
waterQuality.setpH(Double.parseDouble(pH));
if(!aDo.equals("--"))
waterQuality.setdO(Double.parseDouble(aDo));
if(!nh4.equals("--"))
waterQuality.setnH4(Double.parseDouble(nh4));
if(!codMn.equals("--"))
waterQuality.setcODMn(Double.parseDouble(codMn));
if(!toc.equals("--"))
waterQuality.settOC(Double.parseDouble(toc));
if(!level.equals("--"))
waterQuality.setLevel(level);
qualityList.add(waterQuality);
System.out.println(qualityList);
}
}
} catch ( Exception e )
{
System.out.println(e);
} finally
{
//关闭流
try
{
if(is!=null)
{
is.close();
}
if(br!=null)
{
br.close();
}
if (out!=null)
{
out.close();
}
} catch ( Exception ignored )
{
System.out.println(ignored);
}
}
}
}

@ -0,0 +1,175 @@
package util;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
/**
* @author laoyingyong
* @date: 2020-02-05 14:32
*/
public class ExampleUtils
{
public static double getMultipleNum(double n)
{
if(n>=100)
{ return 1;}
else if(n>=90)
{ return 0.9;}
else if(n>=80)
{return 0.8;}
else if(n>=70)
{return 0.7;}
else if(n>=60)
{return 0.6;}
else if(n>=50)
{return 0.5;}
else if(n>=40)
{return 0.4;}
else if(n>=30)
{return 0.3;}
else if(n>=20)
{return 0.2;}
else if(n>=0)
{return 0.1;}
else {System.out.println("倍数不能为负数!");return 0;}//倍数不可能为负数
}
public static double getDistanceNum(double n)
{
if(n>=270)
{ return 1;}
else if(n>=240)
{ return 0.9;}
else if(n>=210)
{return 0.8;}
else if(n>=180)
{return 0.7;}
else if(n>=150)
{return 0.6;}
else if(n>=120)
{return 0.5;}
else if(n>=90)
{return 0.4;}
else if(n>=60)
{return 0.3;}
else if(n>=30)
{return 0.2;}
else if(n>=0)
{return 0.1;}
else {System.out.println("距离不能为负数!");return 0;}//距离不可能为负数
}
public static double getToxicityNum(String toxicity)
{
if(toxicity.equals("微毒"))
{
return 0.1;
}
else if(toxicity.equals("低毒"))
{
return 0.3;
}
else if(toxicity.equals("中等毒"))
{
return 0.5;
}
else if(toxicity.equals("高毒"))
{
return 0.7;
}
else if(toxicity.equals("剧毒"))
{
return 0.9;
}
else
{
System.out.println("污染毒性等级有误!");
return 0;
}
}
public static double getDangerNum(String danger)
{
if(danger.equals("可燃"))
{
return 0.2;
}
else if(danger.equals("易燃"))
{
return 0.5;
}
else if(danger.equals("易燃易爆"))
{
return 0.8;
}
else
{
System.out.println("污染物危险等级有误!");
return 0;
}
}
public static double getStabilityNum(String stability)
{
if(stability.equals("不稳定"))
{
return 0.2;
}
else if(stability.equals("中等"))
{
return 0.5;
}
else if(stability.equals("稳定"))
{
return 0.8;
}
else
{
System.out.println("污染物稳定性等级有误!");
return 0;
}
}
public static double getSolubilityNum(String solubility)
{
if(solubility.equals("不溶于水"))
{
return 0.2;
}
else if(solubility.equals("微溶于水"))
{
return 0.5;
}
else if(solubility.equals("易溶于水"))
{
return 0.8;
}
else
{
System.out.println("污染物溶解性等级有误!");
return 0;
}
}
public static double getVolatilityNum(String volatility)
{
if(volatility.equals("不易挥发"))
{
return 0.2;
}
else if(volatility.equals("中等挥发"))
{
return 0.5;
}
else if(volatility.equals("易挥发"))
{
return 0.8;
}
else
{
System.out.println("污染物挥发性等级有误!");
return 0;
}
}
}

@ -0,0 +1,52 @@
package util;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
/**
* JDBC 使Durid
*/
public class JDBCUtils {
private static DataSource ds ;
static {
try {
//1.加载配置文件
Properties pro = new Properties();
//使用ClassLoader加载配置文件获取字节输入流
InputStream is = JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties");
pro.load(is);
//2.初始化连接池对象
ds = DruidDataSourceFactory.createDataSource(pro);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
*/
public static DataSource getDataSource(){
return ds;
}
/**
* Connection
*/
public static Connection getConnection() throws SQLException {
return ds.getConnection();
}
}

@ -0,0 +1,55 @@
package web.servlet.example;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.Example;
import service.ExampleService;
import service.impl.ExampleServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-05 15:52
*/
@WebServlet("/EmergencyDecisionServlet")
public class EmergencyDecisionServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String type = request.getParameter("type");
String source = request.getParameter("source");
String multiple = request.getParameter("multiple");
String distance = request.getParameter("distance");
String toxicity = request.getParameter("toxicity");
String danger = request.getParameter("danger");
String stability = request.getParameter("stability");
String solubility = request.getParameter("solubility");
String volatility = request.getParameter("volatility");
double v=0;
if(multiple!=null&&!multiple.equals(""))
{v = Double.parseDouble(multiple);}
int i=0;
if(distance!=null&&!distance.equals(""))
{i = Integer.parseInt(distance);}
ExampleService service=new ExampleServiceImpl();
List<Example> resembleExamples = service.findResembleExamples(type, source, v, i, toxicity, danger, stability, solubility, volatility);
response.setContentType("application/json;chartset=utf-8");
ObjectMapper mapper=new ObjectMapper();
mapper.writeValue(response.getOutputStream(),resembleExamples);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,99 @@
package web.servlet.others;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
/**
*
*/
@WebServlet("/checkCodeServlet")
public class CheckCodeServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
//服务器通知浏览器不要缓存
response.setHeader("pragma","no-cache");
response.setHeader("cache-control","no-cache");
response.setHeader("expires","0");
//在内存中创建一个长80宽30的图片默认黑色背景
//参数一:长
//参数二:宽
//参数三:颜色
int width = 80;
int height = 30;
BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
//获取画笔
Graphics g = image.getGraphics();
//设置画笔颜色为灰色
g.setColor(Color.GRAY);
//填充图片
g.fillRect(0,0, width,height);
//产生4个随机验证码12Ey
String checkCode = getCheckCode();
//将验证码放入HttpSession中
request.getSession().setAttribute("CHECKCODE_SERVER",checkCode);
//设置画笔颜色为黄色
g.setColor(Color.YELLOW);
//设置字体的小大
g.setFont(new Font("黑体",Font.BOLD,24));
//向图片上写入验证码
g.drawString(checkCode,15,25);
//2.4画干扰线
g.setColor(Color.GREEN);
//随机生成坐标点
Random ran=new Random();
for (int i = 0; i < 10; i++)
{
int x1 = ran.nextInt(width);
int x2 = ran.nextInt(width);
int y1 = ran.nextInt(height);
int y2 = ran.nextInt(height);
g.drawLine(x1,y1,x2,y2);
}
//将内存中的图片输出到浏览器
//参数一:图片对象
//参数二图片的格式如PNG,JPG,GIF
//参数三:图片输出到哪里去
ImageIO.write(image,"PNG",response.getOutputStream());
}
/**
* 4
*/
private String getCheckCode()
{
String base = "0123456789ABCDEFGHIJKLMNOPQUVWXYZabcdefghijklmnopquvwxyz";
int size = base.length();
Random r = new Random();
StringBuffer sb = new StringBuffer();
for(int i=1;i<=4;i++)
{
//产生0到size-1的随机值
int index = r.nextInt(size);
//在base字符串中获取下标为index的字符
char c = base.charAt(index);
//将c放入到StringBuffer中去
sb.append(c);
}
return sb.toString();
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request,response);
}
}

@ -0,0 +1,76 @@
package web.servlet.others;
import domain.WaterLevel;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-05 10:27
*/
@WebServlet("/DownloadFileServlet")
public class DownloadFileServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
ServletOutputStream outputStream = response.getOutputStream();//网络字节输出流
WaterLevelService service=new WaterLevelServiceImpl();
List<WaterLevel> weekData = service.findWeekData();
outputStream.write(("河流"+"\t"+"测站名"+"\t"+"时间"+"\t"+"水位"+"\t"+"流量"+"\t"+"超警戒(汛限)水位"+"\n").getBytes());
outputStream.write("-----------------------------------------最近七天的水位数据-------------------------------------------\n".getBytes());
for (WaterLevel item : weekData)
{
String riverName = item.getRiverName();
String siteName = item.getSiteName();
Timestamp collectionDate = item.getCollectionDate();
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm");
String format = simpleDateFormat.format(collectionDate);
Double waterLevel = item.getWaterLevel();
Double flow = item.getFlow();
Double over = item.getOver();
outputStream.write((riverName+"\t"+siteName+"\t"+format+"\t"+waterLevel+"\t"+flow+"\t"+over+"\n").getBytes());
}
String filename = request.getParameter("filename");
ServletContext servletContext = request.getServletContext();
//设置响应的mime类型
String mimeType = servletContext.getMimeType(filename);
response.setContentType(mimeType);
String encodeFileName = URLEncoder.encode(filename, "utf-8");//编码,解决文件中文乱码问题
response.setHeader("content-disposition","attachment;filename="+encodeFileName);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,80 @@
package web.servlet.others;
import domain.WaterLevel;
import domain.WaterQuality;
import service.WaterLevelService;
import service.WaterQualityService;
import service.impl.WaterLevelServiceImpl;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-05 10:27
*/
@WebServlet("/DownloadFileServlet2")
public class DownloadFileServlet2 extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
ServletOutputStream outputStream = response.getOutputStream();//网络字节输出流
WaterQualityService service=new WaterQualityServiceImpl();
List<WaterQuality> weekData = service.findWeekData();
outputStream.write(("测站名"+"\t"+"时间"+"\t"+"PH"+"\t"+"溶解氧"+"\t"+"氨氮"+"\t"+"高猛酸钾盐指数"+"\t"+"总有机碳"+"\t"+"水质类别"+"\n").getBytes());
outputStream.write("---------------------------------------------------------------最近七天的水质数据--\n".getBytes());
for (WaterQuality item : weekData)
{
String belongStation = item.getBelongStation();
Timestamp dateTime = item.getDateTime();
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm");
String format = simpleDateFormat.format(dateTime);
Double aDouble = item.getpH();
Double aDouble1 = item.getdO();
Double aDouble2 = item.getnH4();
Double aDouble3 = item.getcODMn();
Double aDouble4 = item.gettOC();
String level = item.getLevel();
outputStream.write((belongStation+"\t"+format+"\t"+aDouble+"\t"+aDouble1+"\t"+aDouble2+"\t"+aDouble3+"\t"+aDouble4+"\t"+level+"\n").getBytes());
}
String filename = request.getParameter("filename");
ServletContext servletContext = request.getServletContext();
//设置响应的mime类型
String mimeType = servletContext.getMimeType(filename);
response.setContentType(mimeType);
String encodeFileName = URLEncoder.encode(filename, "utf-8");//编码,解决文件中文乱码问题
response.setHeader("content-disposition","attachment;filename="+encodeFileName);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,130 @@
package web.servlet.others;
import domain.WaterQuality;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-11 12:12
*/
@WebServlet("/UploadServlet")
public class UploadServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
int count=0;
WaterQualityService service=new WaterQualityServiceImpl();
request.setCharacterEncoding("UTF-8");
//String type=request.getParameter("type");
try {
// 配置上传参数
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
// 解析请求的内容提取文件数据
@SuppressWarnings("unchecked")
List<FileItem> formItems = upload.parseRequest(request);
// 迭代表单数据
for (FileItem item : formItems)
{
// 处理不在表单中的字段
if (!item.isFormField())
{
String fileName = item.getName(); //获取上传的文件名
String fileType=fileName.substring(fileName.lastIndexOf(".")+1);
//定义上传文件的存放路径
String path = request.getServletContext().getRealPath("/upload");
//定义上传文件的完整路径
fileName= new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()).toString();
fileName+="."+fileType; //将文件名字改为时间,避免重名文件
String filePath = String.format("%s\\%s",path,fileName);
File storeFile = new File(filePath);
// 在控制台输出文件的上传路径
System.out.println(path);
System.out.println(filePath);
// 保存文件到硬盘
item.write(storeFile);
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(new FileInputStream(filePath),"utf-8"));//缓冲字符输入流、转换流
String line=null;
while((line=bufferedReader.readLine())!=null)
{
//System.out.println(line);
String[] split = line.split("\t");
System.out.println(Arrays.toString(split));
WaterQuality waterQuality=new WaterQuality();
try
{
waterQuality.setBelongStation(split[0]);
waterQuality.setDateTime(Timestamp.valueOf(split[1]+":00"));
if(!split[2].equals("null"))
{waterQuality.setpH(Double.parseDouble(split[2]));}
if(!split[3].equals("null"))
{waterQuality.setdO(Double.parseDouble(split[3]));}
if(!split[4].equals("null"))
{waterQuality.setnH4(Double.parseDouble(split[4]));}
if(!split[5].equals("null"))
{waterQuality.setcODMn(Double.parseDouble(split[5]));}
if(!split[6].equals("null"))
{waterQuality.settOC(Double.parseDouble(split[6]));}
if(!split[7].equals("null"))
{waterQuality.setLevel(split[7]);}
} catch (Exception e)
{
System.out.println(e);
}
boolean b = service.addOne(waterQuality);
if(b)
{
count++;
}
}
}
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("message",count);
// 跳转到 message.jsp
getServletContext().getRequestDispatcher("/message.jsp").forward(
request, response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,128 @@
package web.servlet.others;
import domain.WaterLevel;
import domain.WaterQuality;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import service.WaterLevelService;
import service.WaterQualityService;
import service.impl.WaterLevelServiceImpl;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-11 12:12
*/
@WebServlet("/UploadServlet2")
public class UploadServlet2 extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
int count=0;
WaterLevelService service=new WaterLevelServiceImpl();
request.setCharacterEncoding("UTF-8");
//String type=request.getParameter("type");
try {
// 配置上传参数
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
// 解析请求的内容提取文件数据
@SuppressWarnings("unchecked")
List<FileItem> formItems = upload.parseRequest(request);
// 迭代表单数据
for (FileItem item : formItems)
{
// 处理不在表单中的字段
if (!item.isFormField())
{
String fileName = item.getName(); //获取上传的文件名
String fileType=fileName.substring(fileName.lastIndexOf(".")+1);
//定义上传文件的存放路径
String path = request.getServletContext().getRealPath("/upload");
//定义上传文件的完整路径
fileName= new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()).toString();
fileName+="."+fileType; //将文件名字改为时间,避免重名文件
String filePath = String.format("%s\\%s",path,fileName);
File storeFile = new File(filePath);
// 在控制台输出文件的上传路径
System.out.println(path);
System.out.println(filePath);
// 保存文件到硬盘
item.write(storeFile);
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(new FileInputStream(filePath),"utf-8"));//缓冲字符输入流、转换流
String line=null;
while((line=bufferedReader.readLine())!=null)
{
//System.out.println(line);
String[] split = line.split("\t");
System.out.println(Arrays.toString(split));
WaterLevel waterLevel=new WaterLevel();
try
{
waterLevel.setRiverName(split[0]);
waterLevel.setSiteName(split[1]);
waterLevel.setCollectionDate(Timestamp.valueOf(split[2]+":00"));
if(!split[3].equals("null"))
{waterLevel.setWaterLevel(Double.parseDouble(split[3]));}
if(!split[4].equals("null"))
{waterLevel.setFlow(Double.parseDouble(split[4]));}
if(!split[5].equals("null"))
{waterLevel.setOver(Double.parseDouble(split[5]));}
} catch (Exception e)
{
System.out.println(e);
}
boolean b = service.addWaterLevelInfo(waterLevel);
if(b)
{
count++;
}
}
}
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("message",count);
// 跳转到 message.jsp
getServletContext().getRequestDispatcher("/otherPage/message2.jsp").forward(
request, response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,81 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import domain.WaterLevel;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-20 20:46
*/
@WebServlet("/AddManyWaterLevelServlet")
public class AddManyWaterLevelServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
int i=0;
WaterLevelService service=new WaterLevelServiceImpl();
Document document = Jsoup.parse(new URL("http://www.hrc.gov.cn/swj/"), 5000);
Elements elements = document.select("[class=shuiqing_table] tr");
List<WaterLevel> list=new ArrayList<>();
for (Element element : elements)//遍历所有行
{
System.out.println(element.text());
WaterLevel waterLevel=new WaterLevel();
Elements tds = element.select("td");
waterLevel.setRiverName(tds.get(0).text());
waterLevel.setSiteName(tds.get(1).text());
try
{
String str=tds.get(2).text()+":00";
waterLevel.setCollectionDate(Timestamp.valueOf(str));
waterLevel.setWaterLevel(Double.parseDouble(tds.get(3).text()));
String liuliang=tds.get(4).text();
if(liuliang.length()!=0&&!liuliang.equals(""))
{
waterLevel.setFlow(Double.parseDouble(tds.get(4).text()));
}
waterLevel.setOver(Double.parseDouble(tds.get(5).text()));
} catch (Exception e)
{
System.out.println(e);
}
list.add(waterLevel);
}
i = service.addManyLevel(list);
System.out.println(list);
ObjectMapper mapper=new ObjectMapper();
ResultInfo info=new ResultInfo();
info.setMsg("总共同步了"+i+"条数据");
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),info);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,83 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import domain.WaterLevel;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;
import java.sql.Timestamp;
@WebServlet("/AddWaterLevelDataServlet")
public class AddWaterLevelDataServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String riverName = request.getParameter("riverName");
String siteName = request.getParameter("siteName");
String collectionDate = request.getParameter("collectionDate");
System.out.println(collectionDate);
String waterLevel = request.getParameter("waterLevel");
String flow = request.getParameter("flow");
String over = request.getParameter("over");
WaterLevel waterLevelObj=new WaterLevel();
try
{
if(riverName!=null&&riverName.length()!=0)
{waterLevelObj.setRiverName(riverName);}
if (siteName!=null&&siteName.length()!=0)
{waterLevelObj.setSiteName(siteName);}
String date="";
if(collectionDate!=null&&collectionDate.length()!=0)
{
date=collectionDate.replace("T"," ")+":00";//多出来一个T,必须去掉
waterLevelObj.setCollectionDate(Timestamp.valueOf(date));
}
if(waterLevel!=null&&waterLevel.length()!=0)
{waterLevelObj.setWaterLevel(Double.parseDouble(waterLevel));}
if(flow!=null&&flow.length()!=0)
{waterLevelObj.setFlow(Double.parseDouble(flow));}
if(over!=null&&over.length()!=0)
{ waterLevelObj.setOver(Double.parseDouble(over));}
} catch (Exception e)
{
System.out.println(e);
}
WaterLevelService service=new WaterLevelServiceImpl();
boolean b = service.addWaterLevelInfo(waterLevelObj);
ResultInfo info=new ResultInfo();
if(b)
{
info.setMsg("添加成功!");
}
else
{
info.setMsg("添加失败,请核对输入数据是否有误!");
}
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),info);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,62 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.PageBean;
import domain.WaterLevel;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
@WebServlet("/ConditionQueryByPageServlet")
public class ConditionQueryByPageServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
WaterLevelService service=new WaterLevelServiceImpl();
Map<String, String[]> parameterMap = request.getParameterMap();
int totalCount = service.conditionalFindAllCount(parameterMap); //总的记录数
String currentPage = request.getParameter("currentPage2");
String pageSize = request.getParameter("pageSize2");
int intCurrentPage = 1;
int intPageSize = 5;
try {
intCurrentPage = Integer.parseInt(currentPage);
intPageSize = Integer.parseInt(pageSize);
} catch (NumberFormatException e) {
System.out.println(e);
}
int totalPage=totalCount%intPageSize==0?totalCount/intPageSize:(totalCount/intPageSize+1);
if(intCurrentPage<=0)
{
intCurrentPage=1;
}
if(intCurrentPage>totalPage)
{
intCurrentPage=totalPage;
}
PageBean<WaterLevel> bean = service.conditionalQueryByPage(intCurrentPage, intPageSize, parameterMap);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;chartset=utf-8");
System.out.println(bean);
mapper.writeValue(response.getOutputStream(),bean);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,72 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterLevel;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-13 14:51
*/
@WebServlet("/CurrentWaterLevelServlet")
public class CurrentWaterLevelServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
Document document = Jsoup.parse(new URL("http://www.hrc.gov.cn/swj/"), 5000);
Elements elements = document.select("[class=shuiqing_table] tr");
List<WaterLevel> list=new ArrayList<>();
for (Element element : elements)//遍历所有行
{
System.out.println(element.text());
WaterLevel waterLevel=new WaterLevel();
Elements tds = element.select("td");
waterLevel.setRiverName(tds.get(0).text());
waterLevel.setSiteName(tds.get(1).text());
try
{
waterLevel.setCollectionDate(Timestamp.valueOf(tds.get(2).text()+":00"));
waterLevel.setWaterLevel(Double.parseDouble(tds.get(3).text()));
String liuliang=tds.get(4).text();
if(liuliang.length()!=0&&!liuliang.equals(""))//流量比较特殊,可能淮河水文局网站上没有给出数据
{
waterLevel.setFlow(Double.parseDouble(tds.get(4).text()));
}
waterLevel.setOver(Double.parseDouble(tds.get(5).text()));
} catch (Exception e)
{
System.out.println(e);
}
list.add(waterLevel);
}
System.out.println(list);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),list);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,46 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/DeleteInfoServlet")
public class DeleteInfoServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String id = request.getParameter("id");
WaterLevelService service=new WaterLevelServiceImpl();
boolean b = service.deleteInfo(Integer.parseInt(id));
ResultInfo info=new ResultInfo();
if(b)
{
info.setMsg("删除成功!");
}
else
{
info.setMsg("删除失败!");
}
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),info);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,63 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.PageBean;
import domain.WaterLevel;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/FindAllByPageServlet")
public class FindAllByPageServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
WaterLevelService service=new WaterLevelServiceImpl();
int totalCount = service.findAllCount();
String currentPage = request.getParameter("currentPage");
String pageSize = request.getParameter("pageSize");
int intCurrentPage = 1;
int intPageSize = 5;
try {
intCurrentPage = Integer.parseInt(currentPage);
intPageSize = Integer.parseInt(pageSize);
} catch (NumberFormatException e) {
System.out.println(e);
}
if(intCurrentPage==0)
{
intCurrentPage = 1;
}
int totalPage=totalCount%intPageSize==0?totalCount/intPageSize:(totalCount/intPageSize+1);
if(intCurrentPage>totalPage)
{
intCurrentPage=totalPage;
}
PageBean<WaterLevel> pageBean = service.findAllByPage(intCurrentPage, intPageSize);
System.out.println(pageBean);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),pageBean);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,41 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterLevel;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-06 12:43
*/
@WebServlet("/FindBySiteNameServlet")
public class FindBySiteNameServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String siteName = request.getParameter("siteName");
WaterLevelService service=new WaterLevelServiceImpl();
List<WaterLevel> list = service.findBySiteName(siteName);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;chartset=utf-8");
mapper.writeValue(response.getOutputStream(),list);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,75 @@
package web.servlet.waterLevel;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import domain.WaterLevel;
import service.WaterLevelService;
import service.impl.WaterLevelServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Map;
@WebServlet("/UpdateWaterLevelData")
public class UpdateWaterLevelData extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String id = request.getParameter("id");
String waterLevel = request.getParameter("shuiwei");
String riverName = request.getParameter("riverName");
String siteName = request.getParameter("siteName");
String over = request.getParameter("chaoguo");
String flow = request.getParameter("flow");
String collectionDate = request.getParameter("caijiriqi");
WaterLevel waterLevelObj=new WaterLevel();
try {
waterLevelObj.setId(Integer.parseInt(id));
waterLevelObj.setWaterLevel(Double.parseDouble(waterLevel));
waterLevelObj.setRiverName(riverName);
waterLevelObj.setSiteName(siteName);
waterLevelObj.setFlow(Double.parseDouble(flow));
waterLevelObj.setOver(Double.parseDouble(over));
waterLevelObj.setCollectionDate(Timestamp.valueOf(collectionDate+":00"));
} catch (Exception e) {
System.out.println(e);
}
System.out.println(waterLevelObj);
WaterLevelService service=new WaterLevelServiceImpl();
boolean update = service.update(waterLevelObj);
ResultInfo info=new ResultInfo();
if(update)
{
info.setMsg("更新成功!");
}
else
{
info.setMsg("更新失败!");
}
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),info);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,88 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Timestamp;
/**
* @author laoyingyong
* @date: 2020-01-20 16:01
*/
@WebServlet("/AddOneWaterQualityServlet")
public class AddOneWaterQualityServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
WaterQualityService service=new WaterQualityServiceImpl();
String belongStation = request.getParameter("belongStation");
String dateTime = request.getParameter("date");
System.out.println(dateTime);
String pH = request.getParameter("ph");
String oxygen = request.getParameter("oxygen");
String nitrogen = request.getParameter("nitrogen");
String permangan = request.getParameter("permangan");
String orgacarbon = request.getParameter("orgacarbon");
String level = request.getParameter("waterQuality");
WaterQuality waterQuality=new WaterQuality();
try
{
if(belongStation!=null&&!belongStation.equals(""))
waterQuality.setBelongStation(belongStation);
if(dateTime!=null&&!dateTime.equals(""))
{waterQuality.setDateTime(Timestamp.valueOf(dateTime.replace("T"," ")+":00"));}
if(pH!=null&&!pH.equals(""))
{waterQuality.setpH(Double.parseDouble(pH));}
if(oxygen!=null&&!oxygen.equals(""))
{waterQuality.setdO(Double.parseDouble(oxygen));}
if(nitrogen!=null&&!nitrogen.equals(""))
{waterQuality.setnH4(Double.parseDouble(nitrogen));}
if(permangan!=null&&!permangan.equals(""))
{waterQuality.setcODMn(Double.parseDouble(permangan));}
if(orgacarbon!=null&&!orgacarbon.equals(""))
{waterQuality.settOC(Double.parseDouble(orgacarbon));}
if (level!=null&&!level.equals(""))
{waterQuality.setLevel(level);}
} catch (Exception e)
{
System.out.println(e);
}finally
{
boolean b = service.addOne(waterQuality);
ResultInfo info=new ResultInfo();
if (b)
{
info.setMsg("添加成功!");
}
else
{
info.setMsg("添加失败!");
}
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf8");
mapper.writeValue(response.getOutputStream(),info);
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,188 @@
package web.servlet.waterQuality;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-20 15:01
*/
@WebServlet("/AddWaterQualityServlet")
public class AddWaterQualityServlet extends HttpServlet
{
private List<WaterQuality> qualityList;
private static String [] siteArray={"沙窝","清河闸","罗庄","密云水库","后城",
"土门楼","万家码头","海河大闸","蓟运河防潮闸",
"于桥水库库中心","三岔口"};
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
WaterQualityService service=new WaterQualityServiceImpl();
//参数字符串,如果拼接在请求链接之后,需要对中文进行 URLEncode 字符集 UTF-8
String param = "AreaID=&RiverID=&MNName=&PageIndex=1&PageSize=60&action=getRealDatas";
StringBuilder sb = new StringBuilder();
InputStream is = null;
BufferedReader br = null;
PrintWriter out = null;
try
{
//接口地址
String url = "https://szzdjc.cnemc.cn:8070/GJZ/Ajax/Publish.ashx";
URL uri = new URL(url);
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestMethod("POST");
connection.setConnectTimeout(50000);
connection.setReadTimeout(12000);
connection.setRequestProperty("accept", "*/*");
//发送参数
connection.setDoOutput(true);
out = new PrintWriter(connection.getOutputStream());
out.print(param);
out.flush();
//接收结果
is = connection.getInputStream();
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line;
//缓冲逐行读取
while ((line = br.readLine()) != null)
{
sb.append(line);
}
String backStr = sb.toString();
String body = backStr;
System.out.println(backStr);
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine engine = sem.getEngineByExtension("js");
String traseStr = null;
try {
traseStr = (String) engine.eval("unescape('" + body + "')");
} catch (ScriptException e) {
e.printStackTrace();
}
traseStr = traseStr.replaceAll("<br>", "\r\n");
traseStr = traseStr.replaceAll("<.*?>", "");
String a= "["+traseStr+"]";
System.out.println(a);
JSONArray jsonArray = JSONObject.parseArray(a);
JSONObject jsonObject = jsonArray.getJSONObject(0);
String jsonArray0 = jsonObject.getString("tbody");
System.out.println(jsonArray0);
JSONArray jsonArray1 = JSONObject.parseArray(jsonArray0);
qualityList=new LinkedList<>();
for (int i = 0; i < jsonArray1.size(); i++)
{
WaterQuality waterQuality=new WaterQuality();
JSONArray jsonArray2= (JSONArray) jsonArray1.get(i);
String siteName = jsonArray2.getString(2);
boolean b = Arrays.asList(siteArray).contains(siteName);
String dateTime = jsonArray2.getString(3);
String pH = jsonArray2.getString(6);
String aDo = jsonArray2.getString(7);
String nh4 = jsonArray2.getString(11);
String codMn = jsonArray2.getString(10);
String toc = jsonArray2.getString(12);
String level = jsonArray2.getString(4);
if (b)
{
System.out.print(siteName+"\t");
System.out.print(dateTime+"\t");
System.out.print(pH+"\t");
System.out.print(aDo+"\t");
System.out.print(nh4+"\t");
System.out.print(codMn+"\t");
System.out.print(toc+"\t");
System.out.println(level);
waterQuality.setBelongStation(siteName);
waterQuality.setDateTime(Timestamp.valueOf("2022-"+dateTime+":00"));
if(!pH.equals("--"))
waterQuality.setpH(Double.parseDouble(pH));
if(!aDo.equals("--"))
waterQuality.setdO(Double.parseDouble(aDo));
if(!nh4.equals("--"))
waterQuality.setnH4(Double.parseDouble(nh4));
if(!codMn.equals("--"))
waterQuality.setcODMn(Double.parseDouble(codMn));
if(!toc.equals("--"))
waterQuality.settOC(Double.parseDouble(toc));
if(!level.equals("--"))
waterQuality.setLevel(level);
qualityList.add(waterQuality);
}
}
} catch (Exception e)
{
System.out.println(e);
} finally
{
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf8");
System.out.println(qualityList);
int add = service.add(qualityList);
ResultInfo info=new ResultInfo();
info.setMsg("总共同步了"+add+"条记录!");
mapper.writeValue(response.getOutputStream(),info);
//关闭流
try {
if (is != null)
{
is.close();
}
if (br != null)
{
br.close();
}
if (out != null)
{
out.close();
}
} catch (Exception ignored)
{
System.out.println(ignored);
}
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,57 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author laoyingyong
* @date: 2020-01-29 23:22
*/
@WebServlet("/DeleteWaterQualityInfoServlet")
public class DeleteWaterQualityInfoServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String id = request.getParameter("id");
WaterQualityService service=new WaterQualityServiceImpl();
int i=0;
try
{
i = Integer.parseInt(id);
} catch (NumberFormatException e)
{
System.out.println(e);
}
boolean del = service.del(i);
ResultInfo info=new ResultInfo();
if(del)
{
info.setMsg("删除成功!");
}
else
{
info.setMsg("删除失败!");
}
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),info);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,41 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-04 20:19
*/
@WebServlet("/FindLineServlet")
public class FindLineServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String stationName = request.getParameter("stationName");//根据请求参数的名称获取请求参数的值
WaterQualityService service=new WaterQualityServiceImpl();
List<WaterQuality> list = service.findByStationName(stationName);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;chartset=utf-8");
mapper.writeValue(response.getOutputStream(),list);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,41 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author laoyingyong
* @date: 2020-01-31 17:44
*/
@WebServlet("/FindNewestServlet")
public class FindNewestServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String stationName = request.getParameter("stationName");
WaterQualityService service=new WaterQualityServiceImpl();
WaterQuality newestRecord = service.findNewestRecord(stationName);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;chartset=utf-8");
mapper.writeValue(response.getOutputStream(),newestRecord);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,39 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-02-02 14:08
*/
@WebServlet("/FindPollutedWaterServlet")
public class FindPollutedWaterServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
WaterQualityService service=new WaterQualityServiceImpl();
List<WaterQuality> pollutedWater = service.findPollutedWater();
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;chartset=utf-8");
mapper.writeValue(response.getOutputStream(),pollutedWater);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,40 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.Statistics;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author laoyingyong
* @date: 2020-01-30 13:03
*/
@WebServlet("/StatisticsWaterQualityServlet")
public class StatisticsWaterQualityServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String stationName = request.getParameter("stationName");
WaterQualityService service=new WaterQualityServiceImpl();
Statistics count = service.count(stationName);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),count);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,78 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.ResultInfo;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Timestamp;
/**
* @author laoyingyong
* @date: 2020-01-29 22:18
*/
@WebServlet("/UpdateWaterQualityInfoServlet")
public class UpdateWaterQualityInfoServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String id = request.getParameter("id");
String belongStation = request.getParameter("belongStation");
String ph = request.getParameter("ph");
String oxygen = request.getParameter("oxygen");
String nitrogen = request.getParameter("nitrogen");
String permangan = request.getParameter("permangan");
String orgacarbon = request.getParameter("orgacarbon");
String level = request.getParameter("phquality");
String time = request.getParameter("time");
WaterQualityService service=new WaterQualityServiceImpl();
WaterQuality waterQuality=new WaterQuality();
try
{
waterQuality.setId(Integer.parseInt(id));
waterQuality.setBelongStation(belongStation);
waterQuality.setpH(Double.parseDouble(ph));
waterQuality.setdO(Double.parseDouble(oxygen));
waterQuality.setnH4(Double.parseDouble(nitrogen));
waterQuality.setcODMn(Double.parseDouble(permangan));
waterQuality.setLevel(level);
waterQuality.setDateTime(Timestamp.valueOf(time+":00"));
waterQuality.settOC(Double.parseDouble(orgacarbon));
} catch (Exception e)
{
System.out.println(e);
}
boolean update = service.update(waterQuality);
ResultInfo info=new ResultInfo();
if(update)
{
info.setMsg("更新成功!");
}
else
{
info.setMsg("更新失败!");
}
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;chartset=utf-8");
mapper.writeValue(response.getOutputStream(),info);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,177 @@
package web.servlet.waterQuality;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterQuality;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-19 15:20
*/
@WebServlet("/ViewCurrentWaterQualityServlet")
public class ViewCurrentWaterQualityServlet extends HttpServlet
{
private List<WaterQuality> qualityList;
private static String [] siteArray={"沙窝","清河闸","罗庄","密云水库","后城",
"土门楼","万家码头","海河大闸","蓟运河防潮闸",
"于桥水库库中心","三岔口"};
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
//参数字符串,如果拼接在请求链接之后,需要对中文进行 URLEncode 字符集 UTF-8
String param = "AreaID=&RiverID=&MNName=&PageIndex=1&PageSize=60&action=getRealDatas";
StringBuilder sb = new StringBuilder();
InputStream is = null;
BufferedReader br = null;
PrintWriter out = null;
try
{
//接口地址
String url = "https://szzdjc.cnemc.cn:8070/GJZ/Ajax/Publish.ashx";
URL uri = new URL(url);
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestMethod("POST");
connection.setConnectTimeout(50000);
connection.setReadTimeout(12000);
connection.setRequestProperty("accept", "*/*");
//发送参数
connection.setDoOutput(true);
out = new PrintWriter(connection.getOutputStream());
out.print(param);
out.flush();
//接收结果
is = connection.getInputStream();
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line;
//缓冲逐行读取
while ((line = br.readLine()) != null)
{
sb.append(line);
}
String backStr = sb.toString();
String body = backStr;
System.out.println(backStr);
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine engine = sem.getEngineByExtension("js");
qualityList=new LinkedList<>();
String traseStr = null;
try {
traseStr = (String) engine.eval("unescape('" + body + "')");
} catch (ScriptException e) {
e.printStackTrace();
}
traseStr = traseStr.replaceAll("<br>", "\r\n");
traseStr = traseStr.replaceAll("<.*?>", "");
String a= "["+traseStr+"]";
System.out.println(a);
JSONArray jsonArray = JSONObject.parseArray(a);
JSONObject jsonObject = jsonArray.getJSONObject(0);
String jsonArray0 = jsonObject.getString("tbody");
System.out.println(jsonArray0);
JSONArray jsonArray1 = JSONObject.parseArray(jsonArray0);
for (int i = 0; i < jsonArray1.size(); i++)
{
WaterQuality waterQuality=new WaterQuality();
JSONArray jsonArray2= (JSONArray) jsonArray1.get(i);
String siteName = jsonArray2.getString(2);
boolean b = Arrays.asList(siteArray).contains(siteName);
String dateTime = jsonArray2.getString(3);
String pH = jsonArray2.getString(6);
String aDo = jsonArray2.getString(7);
String nh4 = jsonArray2.getString(11);
String codMn = jsonArray2.getString(10);
String toc = jsonArray2.getString(12);
String level = jsonArray2.getString(4);
if (b)
{
System.out.print(siteName+"\t");
System.out.print(dateTime+"\t");
System.out.print(pH+"\t");
System.out.print(aDo+"\t");
System.out.print(nh4+"\t");
System.out.print(codMn+"\t");
System.out.print(toc+"\t");
System.out.println(level);
waterQuality.setBelongStation(siteName);
if(!dateTime.equals("--"))
waterQuality.setDateTime(Timestamp.valueOf("2022-"+dateTime+":00"));
if(!pH.equals("--"))
waterQuality.setpH(Double.parseDouble(pH));
if(!aDo.equals("--"))
waterQuality.setdO(Double.parseDouble(aDo));
if(!nh4.equals("--"))
waterQuality.setnH4(Double.parseDouble(nh4));
if(!codMn.equals("--"))
waterQuality.setcODMn(Double.parseDouble(codMn));
if(!toc.equals("--"))
waterQuality.settOC(Double.parseDouble(toc));
if(!level.equals("--"))
waterQuality.setLevel(level);
qualityList.add(waterQuality);
}
}
} catch (Exception e)
{
System.out.println(e);
} finally
{
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf8");
System.out.println(qualityList);
mapper.writeValue(response.getOutputStream(),qualityList);
//关闭流
try {
if (is != null)
{
is.close();
}
if (br != null)
{
br.close();
}
if (out != null)
{
out.close();
}
} catch (Exception ignored)
{
System.out.println(ignored);
}
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,42 @@
package web.servlet.waterQuality;
import com.fasterxml.jackson.databind.ObjectMapper;
import domain.WaterQuality;
import service.WaterQualityService;
import service.impl.WaterQualityServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author laoyingyong
* @date: 2020-01-29 18:25
*/
@WebServlet("/ViewWaterQulityInfoServlet")
public class ViewWaterQulityInfoServlet extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("utf-8");
String stationName = request.getParameter("stationName");
WaterQualityService service=new WaterQualityServiceImpl();
List<WaterQuality> list = service.findByName(stationName);
ObjectMapper mapper=new ObjectMapper();
response.setContentType("application/json;charset=utf-8");
mapper.writeValue(response.getOutputStream(),list);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
this.doPost(request, response);
}
}

@ -0,0 +1,237 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- HTML5文档-->
<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
<head>
<!-- 指定字符集 -->
<meta charset="utf-8">
<!-- 使用Edge最新的浏览器的渲染方式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- viewport视口网页可以根据设置的宽度自动进行适配在浏览器的内部虚拟一个容器容器的宽度与设备的宽度相同。
width: 默认宽度与设备的宽度相同
initial-scale: 初始的缩放比为1:1 -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>添加用户</title>
<!-- 1. 导入CSS的全局样式 -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- 2. jQuery导入建议使用1.9以上的版本 -->
<script src="js/jquery-2.1.0.min.js"></script>
<!-- 3. 导入bootstrap的js文件 -->
<script src="js/bootstrap.min.js"></script>
<style>
#name_sp,#age_sp,#qq_sp,#email_sp{
color: red;
}
</style>
</head>
<body style="background: url('img/img01.jpg') repeat-x;padding-top: 100px">
<div class="container">
<center><h3>添加联系人页面</h3></center>
<form action="${pageContext.request.contextPath}/addUserServlet" method="post" id="form" class="form-horizontal">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">姓名:</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="name" name="name" placeholder="请输入姓名">
</div>
<div class="col-sm-3">
<span id="name_sp"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">性别:</label>
<div class="col-sm-10">
<input type="radio" name="gender" value="男" id="nan" checked="checked"/>男
<input type="radio" name="gender" value="女" id="nv"/>女
</div>
</div>
<div class="form-group">
<label for="age" class="col-sm-2 control-label">年龄:</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="age" name="age" placeholder="请输入年龄">
</div>
<div class="col-sm-3">
<span id="age_sp"></span>
</div>
</div>
<div class="form-group">
<label for="address" class="col-sm-2 control-label">籍贯:</label>
<div class="col-sm-7">
<select name="address" class="form-control" id="address">
<option>--请选择--</option>
<option value="陕西">陕西</option>
<option value="北京">北京</option>
<option value="上海">上海</option>
</select>
</div>
</div>
<div class="form-group">
<label for="qq" class="col-sm-2 control-label">QQ</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="qq" name="qq" placeholder="请输入QQ号码"/>
</div>
<div>
<span id="qq_sp" class="col-sm-3"></span>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-7">
<input type="email" class="form-control" id="email" name="email" placeholder="请输入邮箱地址"/>
</div>
<div class="col-sm-3">
<span id="email_sp"></span>
</div>
</div>
<div class="form-group" style="text-align: center">
<input class="btn btn-primary" type="submit" value="提交" />
<input class="btn btn-default" type="reset" value="重置" />
<input class="btn btn-default" type="button" value="返回" />
</div>
</form>
</div>
<script>
function checkName()
{
var name = document.getElementById("name").value;
var zhengze=/^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/;
var b = zhengze.test(name);
if(b==true)
document.getElementById("name_sp").innerHTML="<img src='img/gou.png' width='50' height='30'>";
else
document.getElementById("name_sp").innerHTML="用户名格式错误";
return b;
}
function checkAge()
{
var age = document.getElementById("age").value;
var zhengze=/^(?:[1-9][0-9]?|1[01][0-9]|120)$/;
var b = zhengze.test(age);
if(b==true)
document.getElementById("age_sp").innerHTML="<img src='img/gou.png' width='50' height='30'>";
else
document.getElementById("age_sp").innerHTML="年龄输入错误";
return b;
}
function cheskQq()
{
var qq = document.getElementById("qq").value;
var zhengze=/^[1-9][0-9]{4,9}$/;
var b = zhengze.test(qq);
if(b==true)
document.getElementById("qq_sp").innerHTML="<img src='img/gou.png' width='50' height='30'>";
else
document.getElementById("qq_sp").innerHTML="qq号格式错误";
return b;
}
function checkEmail()
{
var email = document.getElementById("email").value;
var zhengze=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
var b = zhengze.test(email);
if(b==true)
document.getElementById("email_sp").innerHTML="<img src='img/gou.png' width='50' height='30'>";
else
document.getElementById("email_sp").innerHTML="邮箱格式错误";
return b;
}
var form = document.getElementById("form");
form.onsubmit=function ()
{
checkName();
checkAge();
cheskQq();
checkEmail();
return checkName()&&checkAge()&&cheskQq()&&checkEmail();
}
$("#name").blur(function ()//姓名输入框离焦事件采用jquery的写法
{
var name = $("name").val();
var zhengze=/^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/;
var b = zhengze.test(name);
if(b==true)
$("name_sp").html("<img src='img/gou.png' width='50' height='30'>");
else
$("name_sp").html("用户名格式错误");
});
$("#age").blur(function ()//年龄输入框离焦事件采用jquery的写法
{
var age = $("age").val();
var zhengze=/^(?:[1-9][0-9]?|1[01][0-9]|120)$/;
var b = zhengze.test(age);
if(b==true)
$("age_sp").html("<img src='img/gou.png' width='50' height='30'>");
else
$("age_sp").html("年龄格式错误");
});
$("#qq").blur(function ()//qq输入框离焦事件采用jquery的写法
{
var qq = $("qq").val();
var zhengze=/^[1-9][0-9]{4,9}$/;
var b = zhengze.test(qq);
if(b==true)
$("qq_sp").html("<img src='img/gou.png' width='50' height='30'>");
else
$("qq_sp").html("qq号格式错误");
});
$("#email").blur(function ()//email输入框离焦事件采用jquery的写法
{
var email = $("email").val();
var zhengze=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
var b = zhengze.test(email);
if(b==true)
$("email_sp").html("<img src='img/gou.png' width='50' height='30'>");
else
$("email_sp").html("邮箱格式错误");
});
$("#nan").click(
function ()
{
$("#nan").prop("checked","checked");
}
);
$("#nv").click(
function ()
{
$("#nv").prop("checked","checked");
}
);
$("input[value='返回']").click(function ()
{
window.location.href="${pageContext.request.contextPath}/list.jsp";
});
</script>
</body>
</html>

@ -0,0 +1,170 @@
<%@ page import="java.util.List" %>
<%@ page import="domain.WaterQualityStation" %><%--
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>首页</title>
<!-- 2. jQuery导入建议使用1.9以上的版本 -->
<script src="js/jquery-3.2.1.min.js"></script>
<!-- 1. 导入CSS的全局样式 -->
<link href="css/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/shouye.css">
<!-- 3. 导入bootstrap的js文件 -->
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/init.js">
</script>
</head>
<body style="background: url('img/img01.jpg') repeat-x;padding-top: 52px">
<!--导航条-->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><p class="navbar-text"><span class="glyphicon glyphicon-time" aria-hidden="true"></span>&nbsp;时间:<span id="time_sp" style="color:dodgerblue"></span></p></li>
<c:if test="${user!=null}">
<li><p class="navbar-text"><span class="glyphicon glyphicon-user" aria-hidden="true"></span>&nbsp;<span>用户:</span><a target="myframe" href="../userPage/currentUserInfo.jsp">${user.name}</a></p></li>
</c:if>
<c:if test="${user==null}">
<li><p class="navbar-text"><span class="glyphicon glyphicon-user" aria-hidden="true"></span>&nbsp;<span>用户:</span>未登录</p></li>
</c:if>
<c:if test="${user!=null}">
<li><p class="navbar-text"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span>&nbsp;<a href="${pageContext.request.contextPath}/LogoutServlet">注销</a></p></li>
</c:if>
<c:if test="${user==null}">
<li><p class="navbar-text"><a href="${pageContext.request.contextPath}/login.jsp" style="color: yellow">点击登录</a></p></li>
</c:if>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2" style="height: 700px;">
<div class="leftsidebar_box"><%--侧边菜单栏--%>
<dl>
<dt class="first_dt" ><span class="glyphicon glyphicon-plus"></span>&nbsp;数据采集与录入<img src="img/select_xl01.png"/></dt>
<dd><a href="waterLevelPage/addWaterLevelData.jsp" target="myframe" style="color: white">水位监测数据</a></dd>
<dd><a href="waterQualityPage/addWaterQualityData.jsp" target="myframe" style="color: white">水质监测数据</a></dd>
</dl>
<dl>
<dt><span class="glyphicon glyphicon-blackboard"></span>&nbsp;水质水位信息展示<img src="img/select_xl01.png"/></dt>
<dd><a target="myframe" href="viewMap.jsp" style="color: white">信息展示</a></dd>
</dl>
<dl>
<dt><span class="glyphicon glyphicon-equalizer"></span>&nbsp;数据管理<img src="img/select_xl01.png"/></dt>
<dd ><a href="waterQualityStationPage/viewWaterQualityData.jsp" target="myframe" style="color: white">水质信息管理</a></dd>
<dd> <a href="waterLevelPage/viewWaterLevelInfo.jsp" target="myframe" style="color: white">水位信息管理</a></dd>
</dl>
<dl>
<dt><span class="glyphicon glyphicon-exclamation-sign"></span>&nbsp;预警处理<img src="img/select_xl01.png"/></dt>
<dd> <a href="emergencyPage/emergencyDecision.jsp" target="myframe" style="color: white">预警及相关措施</a></dd>
</dl>
<dl>
<dt><span class="glyphicon glyphicon-user"></span>&nbsp;用户管理<img src="img/select_xl01.png"/></dt>
<dd><a href="updatepassword.jsp" target="myframe" style="color: white">修改当前用户密码</a></dd>
</dl>
</div><%--侧边栏的结尾--%>
</div>
<div class="col-sm-10" style="padding-left: 0px;padding-right: 0px">
<iframe style="width: 100%;height: 700px;border: 0px" name="myframe" src="welcom.jsp"></iframe>
</div>
</div> <%--<div class="row">的结尾--%>
</div><%--container的结尾--%>
<script>
//顶部导航栏的时间
function getCurrentTime()
{
var time=new Date();
var s=dateFormat("yyyy年MM月dd日 HH时mm分ss秒",time);
return s;
}
function f()
{
$("#time_sp").html(getCurrentTime());
}
window.setInterval(f,1000);
function dateFormat(fmt, date) //时间格式化
{
var ret;
var opt =
{
"y+": date.getFullYear().toString(), // 年
"M+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"m+": date.getMinutes().toString(), // 分
"s+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (var k in opt)
{
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret)
{
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}
</script>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save