赞
踩
作者主页:编程指南针
作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助
收藏点赞不迷路 关注作者有好处
文末获取源码
随着社会的发展,社会的各行各业都在利用信息化时代的优势。计算机的优势和普及使得各种信息系统的开发成为必需。
儿童疫苗预约管理,主要的模块包括查看首页、站点管理(轮播图、公告栏)用户管理(管理员、系统用户)内容管理(资讯列表、分类列表)更多管理(预约订单、疫苗信息、取消预约、疫苗采购、疫苗退货)等功能。系统中管理员主要是为了安全有效地存储和管理各类信息,还可以对系统进行管理与更新维护等操作,并且对后台有相应的操作权限。
要想实现儿童疫苗预约管理的各项功能,需要后台数据库的大力支持。管理员验证注册信息,收集的用户信息,并由此分析得出的关联信息等大量的数据都由数据库管理系统管理。本文中数据库服务器端采用了Mysql作为后台数据库,使Web与数据库紧密联系起来。在设计过程中,充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。
本系统的开发使获取儿童疫苗预约管理信息能够更加方便快捷,同时也使儿童疫苗预约管理管理信息变的更加系统化、有序化。系统界面较友好,易于操作。
儿童疫苗预约管理从功能、数据流程、可行性、运行环境等方面进行需求分析。对儿童疫苗预约管理的数据库、功能进行了详细设计。分析了主要界面设计和相关组件设计,对儿童疫苗预约管理的具体实现进行了介绍。
采用Java技术,从数据库中获取数据、向数据库中写入数据,实现系统直接对数据库进行各种操作,在网页中加入动态内容,从而实现儿童疫苗预约管理所需要的各种基本功能。
系统用户分为前端用户和后台管理用户两类:下图展示的是各用户角色功能示例图:
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台开发技术:Springboot+Mybatisplus
前台开发技术:Vue+ElementUi
管理员登录,管理员通过输入用户,密码,角色等信息进行系统登录,如图3-1所示。
图3-1管理员登录界面图
管理员登录进入儿童疫苗预约管理可以查看管理员:首页、站点管理(轮播图、公告栏)用户管理(管理员、系统用户)内容管理(资讯列表、分类列表)更多管理(预约订单、疫苗信息、取消预约、疫苗采购、疫苗退货)等内容,如图3-2所示。
图3-2管理员功能首页界面图
用户管理,在用户管理页面可以查看等索引、用户账号、密码、用户姓名、性别、年龄、联系电话、电子邮箱、身份证号、家庭住址、个人照片等信息,并可根据需要进行修改或删除等操作,如图3-3所示。
图3-3用户管理界面图
疫苗信息,在疫苗信息页面可以查看索引、疫苗编号、疫苗名称、疫苗种类、疫苗详情、接种人群等信息,并可根据需要进行修改或删除等操作,如图3-4所示。
图3-4疫苗信息界面图
预约订单信息,在预约订单信息页面可以查看索引、用户编号、订单编号、疫苗编号、疫苗名称、疫苗价格、接种单位、接种医生等信息,并可根据需要进行修改或删除等操作,如图3-5所示。
图3-5预约订单信息界面图
取消预约,在取消预约页面可以查看索引、疫苗名称、疫苗编号、疫苗名称、疫苗价格、接种单位、单位地址、接种医生等信息,并可根据需要进行修改或删除等操作,如图5-6所示。
图3-6取消预约界面图
用户注册,在用户注册页面通过填写用户账号、密码、用户姓名、年龄、联系电话、电子邮箱、身份等信息完成用户注册,如图3-7所示。
图3-7用户注册界面图
用户登录进入后台可以查看首页、公告消息、疫情资讯、疫苗信息等内容,如图3-9所示。
图3-9用户功能界面图
疫苗信息,在疫苗信息页面可以查看疫苗编号、疫苗名称、疫苗图片等信息操作,如图3-10所示。
图3-10疫苗信息界面图
预约订单管理,在预约订单管理页面可以查看索引、疫苗名称、疫苗编号、接种人群、疫苗价格、接种单位、单位地址、接种医生、接种时间等信息,如图3-11所示。
图3-11预约订单界面图
系统抽像的顶层Controller:
- package com.project.demo.controller.base;
-
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.project.demo.service.base.BaseService;
- import lombok.Setter;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.poi.hssf.usermodel.HSSFWorkbook;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.multipart.MultipartFile;
- import javax.persistence.Query;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.File;
- import java.io.IOException;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- /**
- */
- @Slf4j
- public class BaseController<E, S extends BaseService<E>> {
-
- @Setter
- protected S service;
-
-
- @PostMapping("/add")
- @Transactional
- public Map<String, Object> add(HttpServletRequest request) throws IOException {
- service.insert(service.readBody(request.getReader()));
- return success(1);
- }
-
- @Transactional
- public Map<String, Object> addMap(Map<String,Object> map){
- service.insert(map);
- return success(1);
- }
-
- @PostMapping("/set")
- @Transactional
- public Map<String, Object> set(HttpServletRequest request) throws IOException {
- service.update(service.readQuery(request), service.readConfig(request), service.readBody(request.getReader()));
- return success(1);
- }
-
-
- @RequestMapping(value = "/del")
- @Transactional
- public Map<String, Object> del(HttpServletRequest request) {
- service.delete(service.readQuery(request), service.readConfig(request));
- return success(1);
- }
-
- @RequestMapping("/get_obj")
- public Map<String, Object> obj(HttpServletRequest request) {
- Query select = service.select(service.readQuery(request), service.readConfig(request));
- List resultList = select.getResultList();
- if (resultList.size() > 0) {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("obj",resultList.get(0));
- return success(jsonObject);
- } else {
- return success(null);
- }
- }
-
-
- @RequestMapping("/get_list")
- public Map<String, Object> getList(HttpServletRequest request) {
- Map<String, Object> map = service.selectToPage(service.readQuery(request), service.readConfig(request));
- return success(map);
- }
-
- @RequestMapping("/list_group")
- public Map<String, Object> listGroup(HttpServletRequest request) {
- Map<String, Object> map = service.selectToList(service.readQuery(request), service.readConfig(request));
- return success(map);
- }
-
- @RequestMapping("/bar_group")
- public Map<String, Object> barGroup(HttpServletRequest request) {
- Map<String, Object> map = service.selectBarGroup(service.readQuery(request), service.readConfig(request));
- return success(map);
- }
-
- @RequestMapping(value = {"/count_group", "/count"})
- public Map<String, Object> count(HttpServletRequest request) {
- Query count = service.count(service.readQuery(request), service.readConfig(request));
- return success(count.getResultList());
- }
-
- @RequestMapping(value = {"/sum_group", "/sum"})
- public Map<String, Object> sum(HttpServletRequest request) {
- Query count = service.sum(service.readQuery(request), service.readConfig(request));
- return success(count.getResultList());
- }
-
- @RequestMapping(value = {"/avg_group", "/avg"})
- public Map<String, Object> avg(HttpServletRequest request) {
- Query count = service.avg(service.readQuery(request), service.readConfig(request));
- return success(count.getResultList());
- }
-
-
- @PostMapping("/upload")
- public Map<String, Object> upload(@RequestParam("file") MultipartFile file) {
- log.info("进入方法");
- if (file.isEmpty()) {
- return error(30000, "没有选择文件");
- }
- try {
- //判断有没路径,没有则创建
- String filePath = System.getProperty("user.dir") + "\\target\\classes\\static\\upload\\";
- File targetDir = new File(filePath);
- if (!targetDir.exists() && !targetDir.isDirectory()) {
- if (targetDir.mkdirs()) {
- log.info("创建目录成功");
- } else {
- log.error("创建目录失败");
- }
- }
- // String path = ResourceUtils.getURL("classpath:").getPath() + "static/upload/";
- // String filePath = path.replace('/', '\\').substring(1, path.length());
- String fileName = file.getOriginalFilename();
- File dest = new File(filePath + fileName);
- log.info("文件路径:{}", dest.getPath());
- log.info("文件名:{}", dest.getName());
- file.transferTo(dest);
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("url", "/api/upload/" + fileName);
- return success(jsonObject);
- } catch (IOException e) {
- log.info("上传失败:{}", e.getMessage());
- }
- return error(30000, "上传失败");
- }
-
- @PostMapping("/import_db")
- public Map<String, Object> importDb(@RequestParam("file") MultipartFile file) throws IOException {
- service.importDb(file);
- return success(1);
- }
-
- @RequestMapping("/export_db")
- public void exportDb(HttpServletRequest request, HttpServletResponse response) throws IOException {
- HSSFWorkbook sheets = service.exportDb(service.readQuery(request), service.readConfig(request));
- response.setContentType("application/octet-stream");
- response.setHeader("Content-disposition", "attachment;filename=employee.xls");
- response.flushBuffer();
- sheets.write(response.getOutputStream());
- sheets.close();
- }
-
- public Map<String, Object> success(Object o) {
- Map<String, Object> map = new HashMap<>();
- if (o == null) {
- map.put("result", null);
- return map;
- }
- if (o instanceof List) {
- if (((List) o).size() == 1) {
- o = ((List) o).get(0);
- map.put("result", o);
- }else {
- String jsonString = JSONObject.toJSONString(o);
- JSONArray objects = service.covertArray(JSONObject.parseArray(jsonString));
- map.put("result", objects);
- }
- } else if (o instanceof Integer || o instanceof String) {
- map.put("result", o);
- } else {
- String jsonString = JSONObject.toJSONString(o);
- JSONObject jsonObject = JSONObject.parseObject(jsonString);
- JSONObject j = service.covertObject(jsonObject);
- map.put("result", j);
- }
- return map;
- }
-
- public Map<String, Object> error(Integer code, String message) {
- Map<String, Object> map = new HashMap<>();
- map.put("error", new HashMap<String, Object>(4) {{
- put("code", code);
- put("message", message);
- }});
- return map;
- }
- }
系统抽像的顶层Service:
- package com.project.demo.service.base;
-
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.project.demo.constant.FindConfig;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.poi.hssf.usermodel.*;
- import org.apache.poi.ss.usermodel.*;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.multipart.MultipartFile;
-
- import javax.persistence.EntityManager;
- import javax.persistence.PersistenceContext;
- import javax.persistence.Query;
- import javax.servlet.http.HttpServletRequest;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.UnsupportedEncodingException;
- import java.lang.reflect.ParameterizedType;
- import java.net.URLDecoder;
- import java.security.MessageDigest;
- import java.util.*;
-
- /**
- */
- @Slf4j
- public class BaseService <E>{
-
- @Autowired
- @PersistenceContext
- private EntityManager entityManager;
-
- Class<E> eClass = (Class<E>)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
-
- private final String table = humpToLine(eClass.getSimpleName());
-
- public Query runEntitySql(String sql){
- return entityManager.createNativeQuery(sql, eClass);
- }
-
- public Query runCountSql(String sql){
- return entityManager.createNativeQuery(sql);
- }
-
- public void insert(Map<String,Object> body){
- StringBuffer sql = new StringBuffer("INSERT INTO ");
- sql.append("`").append(table).append("`").append(" (");
- for (Map.Entry<String,Object> entry:body.entrySet()){
- sql.append("`"+humpToLine(entry.getKey())+"`").append(",");
- }
- sql.deleteCharAt(sql.length()-1);
- sql.append(") VALUES (");
- for (Map.Entry<String,Object> entry:body.entrySet()){
- Object value = entry.getValue();
- if (value instanceof String){
- sql.append("'").append(entry.getValue()).append("'").append(",");
- }else {
- sql.append(entry.getValue()).append(",");
- }
- }
- sql.deleteCharAt(sql.length() - 1);
- sql.append(")");
- log.info("[{}] - 插入操作:{}",table,sql);
- Query query = runCountSql(sql.toString());
- query.executeUpdate();
- }
-
- @Transactional
- public void update(Map<String,String> query,Map<String,String> config,Map<String,Object> body){
- StringBuffer sql = new StringBuffer("UPDATE ").append("`").append(table).append("`").append(" SET ");
- for (Map.Entry<String,Object> entry:body.entrySet()){
- Object value = entry.getValue();
- if (value instanceof String){
- sql.append("`"+humpToLine(entry.getKey())+"`").append("=").append("'").append(value).append("'").append(",");
- }else {
- sql.append("`"+humpToLine(entry.getKey())+"`").append("=").append(value).append(",");
- }
-
- }
- sql.deleteCharAt(sql.length()-1);
- sql.append(toWhereSql(query,"0".equals(config.get(FindConfig.LIKE))));
- // sql.append(";");
- log.info("[{}] - 更新操作:{}",table,sql);
- Query query1 = runCountSql(sql.toString());
- query1.executeUpdate();
- }
-
- public Map<String,Object> selectToPage(Map<String,String> query,Map<String,String> config){
- Query select = select(query, config);
- Map<String,Object> map = new HashMap<>();
- map.put("list",select.getResultList());
- map.put("count",count(query,config).getSingleResult());
- return map;
- }
-
- public Map<String,Object> selectToList(Map<String,String> query,Map<String,String> config){
- Query select = selectGroupCount(query, config);
- Map<String,Object> map = new HashMap<>();
- map.put("list",select.getResultList());
- return map;
- }
-
- public Map<String,Object> selectBarGroup(Map<String,String> query,Map<String,String> config){
- Query select = barGroup(query, config);
- Map<String,Object> map = new HashMap<>();
- map.put("list",select.getResultList());
- return map;
- }
-
- public Query barGroup(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer(" SELECT ");
- if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
- sql.append(config.get(FindConfig.GROUP_BY));
- if (config.get(FindConfig.FIELD) != null && !"".equals(config.get(FindConfig.FIELD))){
- String[] fieldList = config.get(FindConfig.FIELD).split(",");
- for (int i=0;i<fieldList.length;i++)
- sql.append(" ,SUM(").append(fieldList[i]).append(")");
- }
- sql.append(" FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
- }else {
- sql.append(" SUM(").append(config.get(FindConfig.GROUP_BY)).append(") FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- }
- log.info("[{}] - 查询操作,sql: {}",table,sql);
- return runCountSql(sql.toString());
- }
-
- public Query selectGroupCount(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer("select COUNT(*) AS count_value, ");
- sql.append(config.get(FindConfig.GROUP_BY)).append(" ");
- sql.append("from ").append("`").append(table).append("` ");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
- sql.append("group by ").append(config.get(FindConfig.GROUP_BY)).append(" ");
- }
- log.info("[{}] - 查询操作,sql: {}",table,sql);
- return runCountSql(sql.toString());
- }
-
- public Query select(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer("select ");
- sql.append(config.get(FindConfig.FIELD) == null || "".equals(config.get(FindConfig.FIELD)) ? "*" : config.get(FindConfig.FIELD)).append(" ");
- sql.append("from ").append("`").append(table).append("`").append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
- sql.append("group by ").append(config.get(FindConfig.GROUP_BY)).append(" ");
- }
- if (config.get(FindConfig.ORDER_BY) != null && !"".equals(config.get(FindConfig.ORDER_BY))){
- sql.append("order by ").append(config.get(FindConfig.ORDER_BY)).append(" ");
- }
- if (config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE))){
- int page = config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE)) ? Integer.parseInt(config.get(FindConfig.PAGE)) : 1;
- int limit = config.get(FindConfig.SIZE) != null && !"".equals(config.get(FindConfig.SIZE)) ? Integer.parseInt(config.get(FindConfig.SIZE)) : 10;
- sql.append(" limit ").append( (page-1)*limit ).append(" , ").append(limit);
- }
- log.info("[{}] - 查询操作,sql: {}",table,sql);
- return runEntitySql(sql.toString());
- }
-
- @Transactional
- public void delete(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer("DELETE FROM ").append("`").append(table).append("`").append(" ");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.GROUP_BY))));
- log.info("[{}] - 删除操作:{}",table,sql);
- Query query1 = runCountSql(sql.toString());
- query1.executeUpdate();
- }
-
- public Query count(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer("SELECT ");
- // log.info("拼接统计函数前");
- if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
- sql.append(config.get(FindConfig.GROUP_BY)).append(" ,COUNT(").append(config.get(FindConfig.GROUP_BY)).append(") FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- // sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
- }else {
- sql.append("COUNT(*) FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- }
- log.info("[{}] - 统计操作,sql: {}",table,sql);
- return runCountSql(sql.toString());
- }
-
- public Query sum(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer(" SELECT ");
- if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
- sql.append(config.get(FindConfig.GROUP_BY)).append(" ,SUM(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
- }else {
- sql.append(" SUM(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- }
- log.info("[{}] - 查询操作,sql: {}",table,sql);
- return runCountSql(sql.toString());
- }
-
- public Query avg(Map<String,String> query,Map<String,String> config){
- StringBuffer sql = new StringBuffer(" SELECT ");
- if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
- sql.append(config.get(FindConfig.GROUP_BY)).append(" ,AVG(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
- }else {
- sql.append(" AVG(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
- sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
- }
- log.info("[{}] - 查询操作,sql: {}",table,sql);
- return runCountSql(sql.toString());
- }
-
- public String toWhereSql(Map<String,String> query, Boolean like) {
- if (query.size() > 0) {
- try {
- StringBuilder sql = new StringBuilder(" WHERE ");
- for (Map.Entry<String, String> entry : query.entrySet()) {
- if (entry.getKey().contains(FindConfig.MIN_)) {
- String min = humpToLine(entry.getKey()).replace("_min", "");
- sql.append("`"+min+"`").append(" >= '").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("' and ");
- continue;
- }
- if (entry.getKey().contains(FindConfig.MAX_)) {
- String max = humpToLine(entry.getKey()).replace("_max", "");
- sql.append("`"+max+"`").append(" <= '").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("' and ");
- continue;
- }
- if (like == true) {
- sql.append("`"+humpToLine(entry.getKey())+"`").append(" LIKE '%").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("%'").append(" and ");
- } else {
- sql.append("`"+humpToLine(entry.getKey())+"`").append(" = '").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("'").append(" and ");
- }
- }
- sql.delete(sql.length() - 4, sql.length());
- sql.append(" ");
- return sql.toString();
- } catch (UnsupportedEncodingException e) {
- log.info("拼接sql 失败:{}", e.getMessage());
- }
- }
- return "";
- }
-
- public Map<String,Object> readBody(BufferedReader reader){
- BufferedReader br = null;
- StringBuilder sb = new StringBuilder("");
- try{
- br = reader;
- String str;
- while ((str = br.readLine()) != null){
- sb.append(str);
- }
- br.close();
- String json = sb.toString();
- return JSONObject.parseObject(json, Map.class);
- }catch (IOException e){
- e.printStackTrace();
- }finally{
- if (null != br){
- try{
- br.close();
- }catch (IOException e){
- e.printStackTrace();
- }
- }
- }
- return null;
- }
-
- public Map<String,String> readQuery(HttpServletRequest request){
- String queryString = request.getQueryString();
- if (queryString != null && !"".equals(queryString)) {
- String[] querys = queryString.split("&");
- Map<String, String> map = new HashMap<>();
- for (String query : querys) {
- String[] q = query.split("=");
- map.put(q[0], q[1]);
- }
- map.remove(FindConfig.PAGE);
- map.remove(FindConfig.SIZE);
- map.remove(FindConfig.LIKE);
- map.remove(FindConfig.ORDER_BY);
- map.remove(FindConfig.FIELD);
- map.remove(FindConfig.GROUP_BY);
- map.remove(FindConfig.MAX_);
- map.remove(FindConfig.MIN_);
- return map;
- }else {
- return new HashMap<>();
- }
- }
-
- public Map<String,String> readConfig(HttpServletRequest request){
- Map<String,String> map = new HashMap<>();
- map.put(FindConfig.PAGE,request.getParameter(FindConfig.PAGE));
- map.put(FindConfig.SIZE,request.getParameter(FindConfig.SIZE));
- map.put(FindConfig.LIKE,request.getParameter(FindConfig.LIKE));
- map.put(FindConfig.ORDER_BY,request.getParameter(FindConfig.ORDER_BY));
- map.put(FindConfig.FIELD,request.getParameter(FindConfig.FIELD));
- map.put(FindConfig.GROUP_BY,request.getParameter(FindConfig.GROUP_BY));
- map.put(FindConfig.MAX_,request.getParameter(FindConfig.MAX_));
- map.put(FindConfig.MIN_,request.getParameter(FindConfig.MIN_));
- return map;
- }
-
- public void importDb(MultipartFile file) throws IOException {
- if (file.isEmpty()) {
- return;
- }
- List<Map<String,String>> body = new ArrayList<>();
- String fileName = file.getOriginalFilename();
- if (fileName == null){
- return;
- }
- String suffix = fileName.substring(fileName.lastIndexOf(".")+1);
- InputStream ins = file.getInputStream();
- Workbook wb = null;
- if(suffix.equals("xlsx")){
- wb = new XSSFWorkbook(ins);
- }else{
- wb = new HSSFWorkbook(ins);
- }
- Sheet sheet = wb.getSheetAt(0);
- if(null != sheet){
- for(int line = 0; line <= sheet.getLastRowNum();line++){
- Row row = sheet.getRow(line);
- if(null == row){
- continue;
- }
- Iterator<Cell> cellIterator = row.cellIterator();
- StringBuffer sql = new StringBuffer("INSERT INTO ").append(table).append(" VALUES (null,");
- while (cellIterator.hasNext()){
- sql.append(cellIterator.next().getStringCellValue()).append(",");
- }
- sql.deleteCharAt(sql.length());
- sql.append(")");
- runCountSql(sql.toString());
- }
- }
- }
-
- public HSSFWorkbook exportDb(Map<String,String> query,Map<String,String> config){
- Query select = select(query, config);
- List<Map<String,String>> resultList = select.getResultList();
- HSSFWorkbook workbook = new HSSFWorkbook();
- HSSFSheet sheet = workbook.createSheet(table);
- HSSFCellStyle headerStyle = workbook.createCellStyle();
- headerStyle.setFillForegroundColor(IndexedColors.YELLOW.index);
- headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- for (int i = 0; i < resultList.size(); i++) {
- HSSFRow row = sheet.createRow(i);
- Map<String,String> map = resultList.get(i);
- int j = 0;
- for (Map.Entry<String,String> entry:map.entrySet()){
- row.createCell(j).setCellValue(new HSSFRichTextString(entry.getValue()));
- }
- }
- return workbook;
- }
-
- @Transactional
- public void save(E e){
- String s = JSONObject.toJSONString(e);
- Map map = JSONObject.parseObject(s, Map.class);
- insert(map);
- }
-
- public E findOne(Map<String, String> map){
- try {
- Query select = select(map, new HashMap<>());
- return (E) select.getSingleResult();
- }catch (Exception e){
- return null;
- }
- }
-
-
- public String encryption(String plainText) {
- String re_md5 = new String();
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update(plainText.getBytes());
- byte b[] = md.digest();
-
- int i;
-
- StringBuffer buf = new StringBuffer("");
- for (int offset = 0; offset < b.length; offset++) {
- i = b[offset];
- if (i < 0)
- i += 256;
- if (i < 16)
- buf.append("0");
- buf.append(Integer.toHexString(i));
- }
-
- re_md5 = buf.toString();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return re_md5;
- }
-
-
- public static String humpToLine(String str) {
- if (str == null) {
- return null;
- }
- // 将驼峰字符串转换成数组
- char[] charArray = str.toCharArray();
- StringBuilder buffer = new StringBuilder();
- //处理字符串
- for (int i = 0, l = charArray.length; i < l; i++) {
- if (charArray[i] >= 65 && charArray[i] <= 90) {
- buffer.append("_").append(charArray[i] += 32);
- } else {
- buffer.append(charArray[i]);
- }
- }
- String s = buffer.toString();
- if (s.startsWith("_")){
- return s.substring(1);
- }else {
- return s;
- }
- }
-
-
- public JSONObject covertObject(JSONObject object) {
- if (object == null) {
- return null;
- }
- JSONObject newObject = new JSONObject();
- Set<String> set = object.keySet();
- for (String key : set) {
- Object value = object.get(key);
- if (value instanceof JSONArray) {
- //数组
- value = covertArray(object.getJSONArray(key));
- } else if (value instanceof JSONObject) {
- //对象
- value = covertObject(object.getJSONObject(key));
- }
- //这个方法自己写的改成下划线
- key = humpToLine(key);
- newObject.put(key, value);
- }
- return newObject;
- }
-
- public JSONArray covertArray(JSONArray array) {
- if (array == null) {
- return null;
- }
- JSONArray newArray = new JSONArray();
- for (int i = 0; i < array.size(); i++) {
- Object value = array.get(i);
- if (value instanceof JSONArray) {
- //数组
- value = covertArray(array.getJSONArray(i));
- } else if (value instanceof JSONObject) {
- //对象
- value = covertObject(array.getJSONObject(i));
- }
- newArray.add(value);
- }
- return newArray;
- }
-
-
- }
随着社会的快速发展,计算机的影响是全面且深入的。人们生活水平的不断提高,日常生活中人们儿童疫苗预约信息管理方面的要求也在不断提高,需要儿童疫苗预约的人数更是不断增加,使得儿童疫苗预约管理的开发成为必需而且紧迫的事情。儿童疫苗预约管理主要是借助计算机,通过对儿童疫苗预约管理所需的信息管理,增加用户选择,同时也方便对广大用户信息的及时查询、修改以及对用户信息的及时了解。儿童疫苗预约管理对用户带来了更多的便利, 该系统通过和数据库管理系统软件协作来满足用户的需求。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。