Compare commits

..

17 Commits

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: 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 @@
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,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,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,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,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);
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,112 @@
<%--
Created by Yingyong Lao.
User: laoyingyong
Date: 2019-12-12
Time: 16:18
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<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">
<script src="../js/bootstrap.min.js"></script>
<script>
$(function () //入口函数
{
$("#waterLevelForm").submit(function ()
{
$.post("../AddWaterLevelDataServlet",$(this).serialize(),function (data)
{
alert(data.msg);
});
return false;//阻止页面跳转
});
});
function addWaterLevel()
{
$.post("../AddManyWaterLevelServlet",function (data)
{
alert(data.msg);
});
}
</script>
</head>
<body style="background:url('../img/img01.jpg') repeat-x">
<div class="container">
<div class="row">
<div class="col-sm-12">
<form id="waterLevelForm" action="AddWaterQualityDataServlet" method="post">
<table class="table table-bordered">
<caption style="text-align: center;font-size: 24px">添加水位监测数据</caption>
<tr class="success">
<th style="text-align: center">河流</th>
<th style="text-align: center">站名</th>
<th style="text-align: center">日期</th>
<th style="text-align: center">水位m</th>
<th style="text-align: center">流量</th>
<th style="text-align: center">超警戒/汛限水位</th>
</tr>
<tr class="info">
<td><input name="riverName" placeholder="海河"></td>
<td><input name="siteName" placeholder="站名"></td>
<td><input type="datetime-local" name="collectionDate"></td>
<td><input type="number" step="0.01" style="width: 80px" name="waterLevel"></td>
<td><input type="number" step="0.1" style="width: 80px" name="flow"></td>
<td><input type="number" step="0.01" style="width: 80px" name="over"></td>
</tr>
<tr class="info">
<td colspan="6" style="text-align: center"><input type="submit" value="添加" class="btn btn-info"></td>
</tr>
</table>
</form>
</div><%--单元格的结尾--%>
</div><%--row end--%>
<div class="row">
<div class="col-sm-4">
<button class="btn btn-info" onclick="addWaterLevel();"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>&nbsp;从水文局同步数据到数据库</button>
</div>
</div>
<div class="row" style="margin-top: 50px">
<div class="col-sm-5">
<form method="post" action="../UploadServlet2" enctype="multipart/form-data">
<table class="table table-bordered">
<caption style="text-align: center;font-size: 24px" >文件上传方式</caption>
<tr>
<td>
<input type="file" name="file" class="btn btn-info" >
</td>
<td>
<input type="submit" value="开始上传水位数据" class="btn btn-info">
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</body>
</html>

@ -0,0 +1,784 @@
<%--
Created by Yingyong Lao.
User: laoyingyong
Date: 2019-12-12
Time: 18:49
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>查看水位信息</title>
<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">
<script src="../js/bootstrap.min.js"></script>
<script>
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;
}
$(function () //入口函数
{
$.post("../FindAllByPageServlet",{currentPage:1,pageSize:5},function (data)//页面加载完成后初始化界面
{
var totalCount = data.totalCount;
var totalPage=data.totalPage;
var currentPage = data.currentPage;
var array = data.list;
//上一页的图标
if(currentPage==1)
{
var str='<li class="disabled" onclick="findByPage('+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
else
{
var str='<li onclick="findByPage('+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
var beginNum;//分页条第一个数字
var endNum;//分页条最后一个数字
if(totalPage<10)//如果总页数小于10页
{
beginNum=1;
endNum=totalPage;
}
else//如果总页数大于等于10页
{
beginNum=currentPage-5;
endNum=currentPage+4;
if(beginNum<1)//currentPage-5可能会是一个小于等于0的数也就是用户在浏览1,2,3,4,5页时的情况
{
beginNum=1;//纠正回来
endNum=beginNum+9;
}
if(endNum>totalPage)//用户在浏览倒数1,2,3,4页时的情况
{
endNum=totalPage;//纠正回来,让分页条最后一个数字为总的页数
beginNum=endNum-9;
}
}
for(var i=beginNum;i<=endNum;i++)//中间分页栏的部分
{
if(i==currentPage)
{
var item=' <li class="active" onclick="findByPage('+i+',5);"><a href="#">'+i+'</a></li>';
}
else
{
var item=' <li onclick="findByPage('+i+',5);"><a href="#">'+i+'</a></li>';
}
str=str+item;
}
if(currentPage==totalPage)
{
var endStr='<li class="disabled" onclick="findByPage('+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页</span>';
}
else
{
var endStr='<li onclick="findByPage('+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页</span>';
}
str=str+endStr;
$("#fenyelan").html(str);//初始化分页栏
var tableStr='<caption style="text-align: center;font-size: 24px">水位信息一览表</caption>\n' +
' <tr class="success">\n' +
' <th style="text-align: center">id</th>\n' +
' <th style="text-align: center">河流</th>\n' +
' <th style="text-align: center">站名</th>\n' +
' <th style="text-align: center">水位m</th>\n' +
' <th style="text-align: center">超过警戒线m</th>\n' +
' <th style="text-align: center">流量</th>\n' +
' <th style="text-align: center">日期</th>\n' +
' <th style="text-align: center">操作</th>\n'+
' </tr>';
for(var i=0;i<array.length;i++)
{
var obj = array[i];
var id = obj.id;
var riverName = obj.riverName;
var siteName = obj.siteName;
var waterLevel = obj.waterLevel;
var over = obj.over;
var flow = obj.flow;
var collectionDate = obj.collectionDate;
var dateTime=dateFormat("yyyy-MM-dd HH:mm",new Date(collectionDate));
var tableItem=' <tr class="info">\n' +
' <td style="text-align: center">'+id+'</td>\n' +
' <td style="text-align: center">'+riverName+'</td>\n' +
' <td style="text-align: center">'+siteName+'</td>\n' +
' <td style="text-align: center">'+waterLevel+'</td>\n' +
' <td style="text-align: center">'+over+'</td>\n' +
' <td style="text-align: center">'+flow+'</td>\n' +
' <td style="text-align: center">'+dateTime+'</td>\n' +
'<td style="text-align: center"><input type="button" onclick="update('+id+',\''+riverName+'\',\''+siteName+'\',\''+waterLevel+'\',\''+over+'\',\''+flow+'\',\''+dateTime+'\');" value="修改" class="btn btn-info">&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="dele('+id+');" type="button" value="删除" class="btn btn-info"></td>\n'+
' </tr>';
tableStr=tableStr+tableItem;
}
$("#waterLevelTable").html(tableStr);
});
});//入口函数end
function findByPage(cuentPage,paSize)//页面按钮被点击时的回调函数
{
$.post("../FindAllByPageServlet",{currentPage:cuentPage,pageSize:paSize},function (data)//页面加载完成后初始化界面
{
var totalCount = data.totalCount;
var totalPage=data.totalPage;
var currentPage = data.currentPage;
var array = data.list;
//上一页的图标
if(currentPage==1)
{
var str='<li class="disabled" onclick="findByPage('+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
else
{
var str='<li onclick="findByPage('+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
var beginNum;//分页条第一个数字
var endNum;//分页条最后一个数字
if(totalPage<10)//如果总页数小于10页
{
beginNum=1;
endNum=totalPage;
}
else//如果总页数大于等于10页
{
beginNum=currentPage-5;
endNum=currentPage+4;
if(beginNum<1)//currentPage-5可能会是一个小于等于0的数也就是用户在浏览1,2,3,4,5页时的情况
{
beginNum=1;//纠正回来
endNum=beginNum+9;
}
if(endNum>totalPage)//用户在浏览倒数1,2,3,4页时的情况
{
endNum=totalPage;//纠正回来,让分页条最后一个数字为总的页数
beginNum=endNum-9;
}
}
for(var i=beginNum;i<=endNum;i++)
{
if(i==currentPage)
{
var item=' <li class="active" onclick="findByPage('+i+',5);"><a href="#">'+i+'</a></li>';
}
else
{
var item=' <li onclick="findByPage('+i+',5);"><a href="#">'+i+'</a></li>';
}
str=str+item;
}
if(currentPage==totalPage)
{
var endStr='<li class="disabled" onclick="findByPage('+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页</span>';
}
else
{
var endStr='<li onclick="findByPage('+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页</span>';
}
str=str+endStr;
$("#fenyelan").html(str);//初始化分页栏
var tableStr='<caption style="text-align: center;font-size: 24px">水位信息一览表</caption>\n' +
' <tr class="success">\n' +
' <th style="text-align: center">id</th>\n' +
' <th style="text-align: center">河流</th>\n' +
' <th style="text-align: center">站名</th>\n' +
' <th style="text-align: center">水位m</th>\n' +
' <th style="text-align: center">超过警戒线m</th>\n' +
' <th style="text-align: center">流量</th>\n' +
' <th style="text-align: center">日期</th>\n' +
' <th style="text-align: center">操作</th>\n'+
' </tr>';
for(var i=0;i<array.length;i++)
{
var obj = array[i];
var id = obj.id;
var riverName = obj.riverName;
var siteName=obj.siteName;
var waterLevel = obj.waterLevel;
var over = obj.over;
var flow = obj.flow;
var collectionDate = obj.collectionDate;
var dateTime=dateFormat("yyyy-MM-dd HH:mm",new Date(collectionDate));
var tableItem=' <tr class="info">\n' +
' <td style="text-align: center">'+id+'</td>\n' +
' <td style="text-align: center">'+riverName+'</td>\n' +
' <td style="text-align: center">'+siteName+'</td>\n' +
' <td style="text-align: center">'+waterLevel+'</td>\n' +
' <td style="text-align: center">'+over+'</td>\n' +
' <td style="text-align: center">'+flow+'</td>\n' +
' <td style="text-align: center">'+dateTime+'</td>\n' +
'<td style="text-align: center"><input type="button" onclick="update('+id+',\''+riverName+'\',\''+siteName+'\',\''+waterLevel+'\',\''+over+'\',\''+flow+'\',\''+dateTime+'\');" value="修改" class="btn btn-info">&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="dele('+id+');" type="button" value="删除" class="btn btn-info"></td>\n'+
' </tr>';
tableStr=tableStr+tableItem;
}
$("#waterLevelTable").html(tableStr);
});
}//回调函数的结尾
//更新按钮的回调函数
function update(id,riverName,siteName,waterLevel,over,flow,collectionDate)
{
var str=' <form id="confirmUpdateForm">\n' +
' <table class="table table-bordered table-hover">\n' +
' <caption style="text-align: center;font-size: 24px">修改数据</caption>\n' +
' <tr class="success">\n' +
' <th style="text-align: center">id</th>\n' +
' <th style="text-align: center">河流</th>\n' +
' <th style="text-align: center">站名</th>\n' +
' <th style="text-align: center">水位m</th>\n' +
' <th style="text-align: center">超过警戒线m</th>\n' +
' <th style="text-align: center">流量</th>\n' +
' <th style="text-align: center">日期</th>\n' +
' <th style="text-align: center">操作</th>\n' +
' </tr>\n' +
' <tr class="info">\n' +
' <td style="text-align: center"><input id="id" name="id" style="width:120px" readonly value="'+id+'"></td>\n' +
' <td style="text-align: center"><input value="'+riverName+'" id="riverName2" style="width:120px"></td>\n' +
' <td style="text-align: center"><input value="'+siteName+'" id="siteName2" style="width:120px"></td>\n' +
' <td style="text-align: center"><input value="'+waterLevel+'" id="shuiwei" type="number" step="0.01" name="shuiwei" placeholder="21.43" style="width:120px" ></td>\n' +
' <td style="text-align: center"><input value="'+over+'" id="chaoguo" type="number" step="0.01" name="chaoguo" placeholder="0" style="width:120px"></td>\n' +
' <td style="text-align: center"><input value="'+flow+'" id="flow" type="number" step="0.1" name="zhuangtai" style="width:120px"></td>\n' +
' <td style="text-align: center"><input value="'+collectionDate+'" id="caijiriqi" name="caijiriqi" type="text"></td>\n' +
' <td style="text-align: center"><input type="button" onclick="updateInfo()" value="确认修改" class="btn btn-info"></td>\n' +
' </tr>\n' +
' </table>\n' +
' </form>';
$("#confirmUpdate_div").html(str);
} //更新按钮的回调函数end
function updateInfo()//确认修改按钮的回调函数
{
var id=$("#id").val();
var riverName=$("#riverName2").val();
var siteName=$("#siteName2").val();
var shuiwei=$("#shuiwei").val();
var chaoguo=$("#chaoguo").val();
var flow=$("#flow").val();
var caijiriqi=$("#caijiriqi").val();
$.get("../UpdateWaterLevelData",{id:id,riverName:riverName,siteName:siteName,shuiwei:shuiwei,chaoguo:chaoguo,flow:flow,caijiriqi:caijiriqi} ,function (data)
{
alert(data.msg);
window.location.href="viewWaterLevelInfo.jsp";
});
}
//删除按钮的回调函数
function dele(id)
{
var b = confirm("您确定要删除吗?");
if(b)
{
$.post("../DeleteInfoServlet",{id:id},function (data)
{
alert(data.msg);
window.location.href="viewWaterLevelInfo.jsp";
});
}
}
//条件查询按钮的回调函数
function searchByCondition()
{
var riverName=$("#riverName").val();
var siteName=$("#siteName").val();
var collectionDate=$("#collectionDate").val();
$.post("../ConditionQueryByPageServlet",{riverName:riverName,siteName:siteName,collectionDate:collectionDate,currentPage2:1,pageSize2:5},function (data)
{
//alert(data);
var totalCount = data.totalCount;
if(totalCount==0)
{
alert("数据库中没有记录!");
}
var totalPage = data.totalPage;
var currentPage = data.currentPage;
var array = data.list;
var tableStr=' <caption style="text-align: center;font-size: 24px">查询结果</caption>\n' +
' <tr class="success">\n' +
' <th style="text-align: center">id</th>\n' +
' <th style="text-align: center">河流</th>\n' +
' <th style="text-align: center">站名</th>\n' +
' <th style="text-align: center">水位m</th>\n' +
' <th style="text-align: center">超过警戒线m</th>\n' +
' <th style="text-align: center">流量</th>\n' +
' <th style="text-align: center">日期</th>\n' +
' <th style="text-align: center">操作</th>\n' +
' </tr>';
for(var i=0;i<array.length;i++)
{
var obj = array[i];
var id = obj.id;
var riverName2 = obj.riverName;
var siteName2=obj.siteName;
var waterLevel = obj.waterLevel;
var over = obj.over;
var flow= obj.flow;
var collectionDate2 = obj.collectionDate;
var dateStr=dateFormat("yyyy-MM-dd HH:mm",new Date(collectionDate2));
var item=' <tr class="info">\n' +
' <td style="text-align: center">'+id+'</td>\n' +
' <td style="text-align: center">'+riverName2+'</td>\n' +
' <td style="text-align: center">'+siteName2+'</td>\n' +
' <td style="text-align: center">'+waterLevel+'</td>\n' +
' <td style="text-align: center">'+over+'</td>\n' +
' <td style="text-align: center">'+flow+'</td>\n' +
' <td style="text-align: center">'+dateStr+'</td>\n' +
'<td style="text-align: center"><input type="button" onclick="update('+id+',\''+riverName2+'\',\''+siteName2+'\',\''+waterLevel+'\',\''+over+'\',\''+flow+'\',\''+dateStr+'\');" value="修改" class="btn btn-info">&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="dele('+id+');" type="button" value="删除" class="btn btn-info"></td>\n'+
' </tr>';
tableStr+=item;
}
var endStr=' </table>';
tableStr+=endStr;
$("#waterLevelTable").html(tableStr);
if(currentPage==1)
{
var fenyelanStr=' <li class="disabled" onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
else
{
var fenyelanStr=' <li onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
var beginNum;//分页条第一个数字
var endNum;//分页条最后一个数字
if(totalPage<10)//如果总页数小于10页
{
beginNum=1;
endNum=totalPage;
}
else//如果总页数大于等于10页
{
beginNum=currentPage-5;
endNum=currentPage+4;
if(beginNum<1)//currentPage-5可能会是一个小于等于0的数也就是用户在浏览1,2,3,4,5页时的情况
{
beginNum=1;//纠正回来
endNum=beginNum+9;
}
if(endNum>totalPage)//用户在浏览倒数1,2,3,4页时的情况
{
endNum=totalPage;//纠正回来,让分页条最后一个数字为总的页数
beginNum=endNum-9;
}
}
for(var i=beginNum;i<=endNum;i++)
{
if(i==currentPage)
{
var middleStr='<li class="active" onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+i+',5);"><a href="#">'+i+'</a></li>';
fenyelanStr+=middleStr;
}
else
{
var middleStr='<li onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+i+',5);"><a href="#">'+i+'</a></li>';
fenyelanStr+=middleStr;
}
}
if(currentPage==totalPage)
{
var lastStr='<li class="disabled" onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页&nbsp;&nbsp;' +
'<input type="button" class="btn btn-info btn-sm" value="返回一览表" onclick="fuwei();"></span>';
}
else
{
var lastStr='<li onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页&nbsp;&nbsp;' +
'<input type="button" class="btn btn-info btn-sm" value="返回一览表" onclick="fuwei();"></span>';
}
fenyelanStr+=lastStr;
$("#fenyelan").html(fenyelanStr);
});//异步请求end
}
function fuwei()
{
window.location.href='viewWaterLevelInfo.jsp';
}
function findByPage2(riverName,siteName,collectionDate,currentPage,pageSize)
{
$.post("../ConditionQueryByPageServlet",{riverName:riverName,siteName:siteName,collectionDate:collectionDate,currentPage2:currentPage,pageSize2:pageSize},function (data)
{
var totalCount = data.totalCount;
if(totalCount==0)
{
alert("数据库中没有记录!");
}
var totalPage = data.totalPage;
var currentPage = data.currentPage;
var array = data.list;
var tableStr=' <caption style="text-align: center;font-size: 24px">查询结果</caption>\n' +
' <tr class="success">\n' +
' <th style="text-align: center">id</th>\n' +
' <th style="text-align: center">河流</th>\n' +
' <th style="text-align: center">站名</th>\n' +
' <th style="text-align: center">水位m</th>\n' +
' <th style="text-align: center">超过警戒线m</th>\n' +
' <th style="text-align: center">流量</th>\n' +
' <th style="text-align: center">日期</th>\n' +
' <th style="text-align: center">操作</th>\n' +
' </tr>';
for(var i=0;i<array.length;i++)
{
var obj = array[i];
var id = obj.id;
var riverName2 = obj.riverName;
var siteName2=obj.siteName;
var waterLevel = obj.waterLevel;
var over = obj.over;
var flow= obj.flow;
var collectionDate2 = obj.collectionDate;
var dateStr=dateFormat("yyyy-MM-dd HH:mm",new Date(collectionDate2));
var item=' <tr class="info">\n' +
' <td style="text-align: center">'+id+'</td>\n' +
' <td style="text-align: center">'+riverName2+'</td>\n' +
' <td style="text-align: center">'+siteName2+'</td>\n' +
' <td style="text-align: center">'+waterLevel+'</td>\n' +
' <td style="text-align: center">'+over+'</td>\n' +
' <td style="text-align: center">'+flow+'</td>\n' +
' <td style="text-align: center">'+dateStr+'</td>\n' +
'<td style="text-align: center"><input type="button" onclick="update('+id+',\''+riverName2+'\',\''+siteName2+'\',\''+waterLevel+'\',\''+over+'\',\''+flow+'\',\''+dateStr+'\');" value="修改" class="btn btn-info">&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="dele('+id+');" type="button" value="删除" class="btn btn-info"></td>\n'+
' </tr>';
tableStr+=item;
}
var endStr=' </table>';
tableStr+=endStr;
$("#waterLevelTable").html(tableStr);
if(currentPage==1)
{
var fenyelanStr=' <li class="disabled" onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
else
{
var fenyelanStr=' <li onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage-1)+',5);">\n' +
' <a href="#" aria-label="Previous">\n' +
' <span aria-hidden="true">&laquo;</span>\n' +
' </a>\n' +
' </li>';
}
var beginNum;//分页条第一个数字
var endNum;//分页条最后一个数字
if(totalPage<10)//如果总页数小于10页
{
beginNum=1;
endNum=totalPage;
}
else//如果总页数大于等于10页
{
beginNum=currentPage-5;
endNum=currentPage+4;
if(beginNum<1)//currentPage-5可能会是一个小于等于0的数也就是用户在浏览1,2,3,4,5页时的情况
{
beginNum=1;//纠正回来
endNum=beginNum+9;
}
if(endNum>totalPage)//用户在浏览倒数1,2,3,4页时的情况
{
endNum=totalPage;//纠正回来,让分页条最后一个数字为总的页数
beginNum=endNum-9;
}
}
for(var i=beginNum;i<=endNum;i++)
{
if(i==currentPage)
{
var middleStr='<li class="active" onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+i+',5);"><a href="#">'+i+'</a></li>';
fenyelanStr+=middleStr;
}
else
{
var middleStr='<li onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+i+',5);"><a href="#">'+i+'</a></li>';
fenyelanStr+=middleStr;
}
}
if(currentPage==totalPage)
{
var lastStr='<li class="disabled" onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页&nbsp;&nbsp;' +
'<input type="button" class="btn btn-info btn-sm" value="返回一览表" onclick="fuwei();"></span>';
}
else
{
var lastStr='<li onclick="findByPage2(\''+riverName+'\',\''+siteName+'\',\''+collectionDate+'\','+(currentPage+1)+',5);">\n' +
' <a href="#" aria-label="Next">\n' +
' <span aria-hidden="true">&raquo;</span>\n' +
' </a>\n' +
' </li>\n' +
' <span style="font-size: 24px" id="total_sp">共'+totalCount+'条记录,共'+totalPage+'页&nbsp;&nbsp;' +
'<input type="button" class="btn btn-info btn-sm" value="返回一览表" onclick="fuwei();"></span>';
}
fenyelanStr+=lastStr;
$("#fenyelan").html(fenyelanStr);
});
}
</script>
</head>
<body style="background: url('../img/img01.jpg') repeat-x">
<div class="container">
<div class="row">
<div class="col-sm-8" style="margin-top: 20px">
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="riverName">Email address</label>
<input type="text" class="form-control" id="riverName" name="name2" placeholder="河流、湖泊">
</div>
<div class="form-group">
<label class="sr-only" for="siteName">Password</label>
<input type="text" class="form-control" id="siteName" name="status2" placeholder="站名">
</div>
<div class="form-group">
<label class="sr-only" for="collectionDate">Password</label>
<input type="text" class="form-control" id="collectionDate" name="status2" placeholder="时间">
</div>
<button type="button" onclick="searchByCondition();" class="btn btn-warning">搜索</button>
</form>
</div>
</div><%--row end--%>
<div class="row">
<div class="col-sm-10" id="waterLevelTableDiv">
<table class="table table-bordered table-hover" id="waterLevelTable">
<caption style="text-align: center;font-size: 24px">水位信息一览表</caption>
<tr class="success">
<th style="text-align: center">id</th>
<th style="text-align: center">地点名称</th>
<th style="text-align: center">水位m</th>
<th style="text-align: center">超过警戒线m</th>
<th style="text-align: center">状态</th>
<th style="text-align: center">采集日期</th>
<th style="text-align: center">操作</th>
</tr>
<tr class="info">
<td style="text-align: center">id</td>
<td style="text-align: center">地点名称</td>
<td style="text-align: center">水位m</td>
<td style="text-align: center">超过警戒线m</td>
<td style="text-align: center">状态OK/NO</td>
<td style="text-align: center">采集日期</td>
<td style="text-align: center"><input type="button" onclick="update(1);" value="修改" class="btn btn-info">&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="dele(1);" type="button" value="删除" class="btn btn-info"></td>
</tr>
</table>
<nav aria-label="Page navigation">
<ul class="pagination" id="fenyelan">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li><a href="#">1</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
<span style="font-size: 24px" id="total_sp">共2条记录共1页</span>
</ul>
</nav>
</div>
</div>
<div class="row">
<hr style="background-color: silver;border: none;height: 2px">
</div>
<div class="row">
<div class="col-sm-10" id="confirmUpdate_div">
</div>
</div>
</div>
</body>
</html>

@ -0,0 +1,224 @@
<%--
Created by Yingyong Lao.
User: laoyingyong
Date: 2019-12-11
Time: 18:43
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>添加水质质量数据</title>
<script src="../js/jquery-ui.js"></script>
<!-- 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/jquery-ui.min.css">
<script src="../js/bootstrap.min.js"></script>
<script>
$(function ()
{
$.post("../FindAlllStationServlet",function (data)
{
for (var i = 0; i <data.length ; i++)
{
var obj=data[i];
var stationName=obj.stationName;
var optionStr='<option value="'+stationName+'">'+stationName+'</option>';
$("#belongStation").append(optionStr);
}
});
$("#stationForm").submit(function ()
{
$.get("../AddWaterQualityDataServlet",$("#stationForm").serialize(),function (data)//serialize()千万别少写了括号哦
{
var msg=data.msg;
var str='<div class="alert alert-warning alert-dismissible" role="alert">\n' +
' <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n' +
' <strong>提示:</strong>'+msg+'\n' +
'</div>';
$("#msg_div").html(str);
});
return false;//阻止页面跳转
});
});
function addSomeWaterQuality()
{
$.post("../AddWaterQualityServlet",function (data)
{
var msg=data.msg;
alert(msg);
});
}
function getStation()
{
var belongStation = $("#belongStation").val();
return belongStation;
}
function addOneWaterQuality()
{
var belongStation = getStation();
var waterQuality=getQualityLevel();
var date = $("#date").val();
var ph = $("#ph").val();
var oxygen = $("#oxygen").val();
var nitrogen=$("#nitrogen").val();
var permangan = $("#permangan").val();
var orgacarbon=$("#orgacarbon").val();
$.post("../AddOneWaterQualityServlet",{belongStation:belongStation,date:date,ph:ph,oxygen:oxygen,nitrogen:nitrogen,permangan:permangan,orgacarbon:orgacarbon,waterQuality:waterQuality},function (data)
{
alert(data.msg);
});
}
function getQualityLevel()
{
var a = $("#qualitySelect").val();
return a;
}
</script>
</head>
<body style="background: url('../img/img01.jpg') repeat-x;">
<div class="container">
<div class="row">
<div class="col-sm-8">
<form id="stationForm" action="AddWaterQualityDataServlet" method="post">
<table class="table table-bordered">
<caption style="text-align: center;font-size: 24px">添加水质监测站</caption>
<tr class="success">
<th style="text-align: center">监测站名称</th>
<th style="text-align: center">经度</th>
<th style="text-align: center">纬度</th>
<th style="text-align: center">所属断面</th>
<th style="text-align: center">简介</th>
</tr>
<tr class="info">
<td><input name="stationName" placeholder="安徽宿州杨庄"></td>
<td><input name="longitude" placeholder="经度"></td>
<td><input name="latitude" placeholder="纬度"></td>
<td><input name="section" placeholder="苏-皖省界"></td>
<td><textarea rows="5" cols="20" name="introduction" placeholder="安徽宿州杨庄水质自动监测站位于宿州市杨庄乡伊桥村。点位坐标北纬34度03分43秒东经117度13分12秒。属淮河流域奎河苏-皖省界。由安徽省宿州环境监测站管理。距水站77公里。建于2006年12月。"></textarea></td>
</tr>
<tr class="info">
<td colspan="2" style="text-align: center"><input id="addStation_Btn" type="submit" value="添加" class="btn btn-info"></td>
<td colspan="3"> <div id="msg_div"></div></td>
</tr>
</table>
</form>
</div><%--单元格的结尾--%>
</div><%--row end--%>
<div class="row" style="padding-top: 50px"><%--第二行--%>
<div class="col-md-12">
<table class="table table-bordered table-responsive table-condensed">
<caption style="text-align: center;font-size: 24px">手动添加水质监测数据</caption>
<tr class="success">
<th style="text-align: center">所属测站名</th>
<th style="text-align: center">PH</th>
<th style="text-align: center">溶解氧</th>
<th style="text-align: center">氨氮</th>
<th style="text-align: center">高猛酸钾指数</th>
<th style="text-align: center">总有机碳</th>
<th style="text-align: center">水质类别</th>
<th style="text-align: center">测量时间</th>
</tr>
<tr class="info">
<td>
<select id="belongStation" onchange="getStation();">
<option>--请选择--</option>
</select>
</td>
<td><input type="number" step="0.01" style="width: 120px" id="ph" name="ph" placeholder="8.02"></td>
<td><input type="number" step="0.01" style="width: 110px" id="oxygen" name="oxygen" placeholder="11.33"></td>
<td><input type="number" step="0.01" style="width: 120px" name="nitrogen" id="nitrogen" placeholder="1.39"></td>
<td><input type="number" step="0.01" style="width: 120px" name="permangan" id="permangan" placeholder="3.5"></td>
<td><input type="number" step="0.01" style="width: 120px" name="orgacarbon" id="orgacarbon" placeholder="0.8"></td>
<td>
<select id="qualitySelect" onchange="getQualityLevel();">
<option>--请选择--</option>
<option value="I"></option>
<option value="II">Ⅱ</option>
<option value="III">Ⅲ</option>
<option value="IV">Ⅳ</option>
<option value="V"></option>
<option value="劣V">劣Ⅴ</option>
</select>
</td>
<td><input type="datetime-local" style="width: 180px" name="date" id="date" placeholder="2019-12-11 12:00"></td>
</tr>
<tr class="info">
<td colspan="4" style="text-align: center"><input onclick="addOneWaterQuality();" type="button" value="添加" class="btn btn-info"></td>
<td colspan="5"></td>
</tr>
</table>
</div><%--单元格的结尾--%>
</div><%--第二行end--%>
<div class="row" style="padding-top:50px">
<div class="col-sm-3 ">
<table class="table table-bordered">
<caption style="text-align: center;font-size: 24px">一键添加多条水质数据</caption>
<tr>
<td><button onclick="addSomeWaterQuality();" class="btn btn-info"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>&nbsp;从“中国环境监测总站”同步数据到数据库</button></td>
</tr>
</table>
</div>
<div class="col-sm-5 col-sm-offset-3">
<form method="post" enctype="multipart/form-data" action="../UploadServlet">
<table class="table table-bordered">
<caption style="text-align: center;font-size: 24px">文件上传方式</caption>
<tr>
<td>
<input type="file" class="btn-info btn" name="file">
</td>
<td>
<input type="submit" value="开始上传水质数据" class="btn btn-info" style="float: left">
</td>
</tr>
</table>
</form>
</div>
</div>
</div><%--container容器end--%>
</body>
</html>

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save