标签:php servlet factor efault ase myeclipse 针对 管理员 www
大家好,我是全微毕设团队的创始人,本团队擅长JAVA(SSM,SSH,SPRINGBOOT)、PYTHON、PHP、C#、安卓等多项技术。
今天将为大家分析一个车辆故障管理系统(本文针对汽车故障诊断专家系统 中知识库的特点,设计了一种基于Windows平台的知识库管理系统(KnowledgebaseManagementSystem以下简称KBMS), 该系统充分利用了数据库技术,实现了对知识库中知识的存储、增加、删除、修改和查询,以及对知识进行一致性和完整性校验,为汽车故障诊断专家系统的开发和 运用奠定了重要基础。),该项目使用框架为SSM(MYECLIPSE),选用开发工具为MYECLIPSE。车辆故障管理系统为一个 后台项目。
为了完成该系统,我们首先需要对该系统进行需求分析。一个车辆故障管理系统应包含用户角色有管理员、车主、员工。为了能让用户顺利登陆系统完成相关操作,需要为每种登陆角色设置账户和密码字段。
为了完成系统的功能需要为车主设置车辆表,记录车辆信息。在车辆表中定义了两者的关联关系,其中车辆的车主与车主的mingzi字段对应、车辆的车主id与车主的id字段对应
。
总结得出该系统所有数据为:管理员(admin)、车辆(cheliang)、车主(chezhu)、员工(yuangong)
管理员表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 管理员id username | VARCHAR(255) | | 账号 password | VARCHAR(255) | | 密码
车辆表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 车辆id chepai | VARCHAR(255) | | 车牌 chezhu | VARCHAR(255) | | 车主 chezhuid | VARCHAR(255) | | 车主id zhuangtai | VARCHAR(255) | | 状态
车主表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 车主id mingzi | VARCHAR(255) | | 名字 lianxi | VARCHAR(255) | | 联系方式
员工表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 员工id mingzi | VARCHAR(255) | | 名字 username | VARCHAR(255) | | 账号 password | VARCHAR(255) | | 密码
sql建表语句
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- ---------------------------- -- Table structure for ggcheliangguzhang -- ---------------------------- DROP TABLE IF EXISTS `t_admin`; CREATE TABLE `t_admin` (`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT ‘管理员id‘,`username` VARCHAR(255) DEFAULT NULL COMMENT ‘账号‘,`password` VARCHAR(255) DEFAULT NULL COMMENT ‘密码‘,PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘管理员‘; -- ---------------------------- DROP TABLE IF EXISTS `t_cheliang`; CREATE TABLE `t_cheliang` (`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT ‘车辆id‘,`chepai` VARCHAR(255) DEFAULT NULL COMMENT ‘车牌‘,`chezhu` VARCHAR(255) DEFAULT NULL COMMENT ‘车主‘,`chezhuid` INT(11) DEFAULT NULL COMMENT ‘车主id‘,`zhuangtai` VARCHAR(255) DEFAULT NULL COMMENT ‘状态‘,PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘车辆‘; -- ---------------------------- DROP TABLE IF EXISTS `t_chezhu`; CREATE TABLE `t_chezhu` (`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT ‘车主id‘,`mingzi` VARCHAR(255) DEFAULT NULL COMMENT ‘名字‘,`lianxi` VARCHAR(255) DEFAULT NULL COMMENT ‘联系方式‘,PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘车主‘; -- ---------------------------- DROP TABLE IF EXISTS `t_yuangong`; CREATE TABLE `t_yuangong` (`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT ‘员工id‘,`mingzi` VARCHAR(255) DEFAULT NULL COMMENT ‘名字‘,`username` VARCHAR(255) DEFAULT NULL COMMENT ‘账号‘,`password` VARCHAR(255) DEFAULT NULL COMMENT ‘密码‘,PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘员工‘;
员工处理模块
package org.mypro.front; import java.io.File; import java.io.IOException; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.List; import javax.jms.Session; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mypro.dao.YuangongMapper; import org.mypro.entity.Yuangong; import org.mypro.entity.YuangongExample; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; @Controller @RequestMapping(value = "/") public class YuangongController { private static final Log logger = LogFactory.getLog(YuangongController.class); @Autowired private YuangongMapper yuangongdao; //定义方法tianjiayuangong,响应页面tianjiayuangong请求 @RequestMapping(value = "tianjiayuangong") public String tianjiayuangong(HttpServletRequest request, HttpServletResponse response,HttpSession session,String backurl) { logger.debug("YuangongController.tianjiayuangong ......"); if(backurl != null && backurl.indexOf("tianjiayuangong.action") == -1){ return "forward:/" + backurl; } return "tianjiayuangong"; } @RequestMapping(value = "tianjiayuangongact") public String tianjiayuangongact(HttpServletRequest request,HttpSession session, HttpServletResponse response,Yuangong yuangong,String backurl) throws IOException { logger.debug("YuangongController.tianjiayuangongact ......"); yuangongdao.insert(yuangong); request.setAttribute("message", "添加员工成功"); if(backurl != null && backurl.indexOf("tianjiayuangongact.action") == -1){ return "forward:/" + backurl; } //返回tianjiayuangong方法 return "forward:/tianjiayuangong.action"; } //定义yuangongguanli方法响应页面请求 @RequestMapping(value = "yuangongguanli") public String yuangongguanli(HttpServletRequest request,HttpSession session, HttpServletResponse response,String backurl) { logger.debug("YuangongController.yuangongguanli ......"); YuangongExample example = new YuangongExample(); List yuangongall = yuangongdao.selectByExample(example); request.setAttribute("yuangongall", yuangongall); if(backurl != null && backurl.indexOf("yuangongguanli.action") == -1){ return "forward:/" + backurl; } return "yuangongguanli"; } // 定义 yuangongchakan方法 @RequestMapping(value = "yuangongchakan") public String yuangongchakan(HttpServletRequest request,HttpSession session, HttpServletResponse response,String backurl) { logger.debug("YuangongController.yuangongchakan ......"); YuangongExample example = new YuangongExample(); List yuangongall = yuangongdao.selectByExample(example); request.setAttribute("yuangongall", yuangongall); if(backurl != null && backurl.indexOf("yuangongchakan.action") == -1){ return "forward:/" + backurl; } return "yuangongchakan"; } // 定义 xiugaiyuangong方法 @RequestMapping(value = "xiugaiyuangong") public String xiugaiyuangong(HttpServletRequest request, HttpServletResponse response,HttpSession session,int id,String backurl){ logger.debug("YuangongController.xiugaiyuangong ......"); Yuangong yuangong = yuangongdao.selectByPrimaryKey(id); request.setAttribute("yuangong", yuangong); if(backurl != null && backurl.indexOf("xiugaiyuangong.action") == -1){ return "forward:/" + backurl; } return "xiugaiyuangong"; } // 定义xiugaiyuangongact处理员工修改 @RequestMapping(value = "xiugaiyuangongact") public String xiugaiyuangongact(HttpServletRequest request, HttpServletResponse response,Yuangong yuangong,HttpSession session,String backurl) throws IOException { logger.debug("YuangongController.xiugaiyuangongact ......"); yuangongdao.updateByPrimaryKeySelective(yuangong); request.setAttribute("message", "修改员工信息成功"); if(backurl != null && backurl.indexOf("xiugaiyuangongact.action") == -1){ return "forward:/" + backurl; } return "forward:/yuangongguanli.action"; } // 定义shanchuyuangong,处理删除员工 @RequestMapping(value = "shanchuyuangong") public String shanchuyuangong(HttpServletRequest request, HttpServletResponse response,HttpSession session,int id,String backurl){ logger.debug("YuangongController.shanchuyuangong ......"); yuangongdao.deleteByPrimaryKey(id); request.setAttribute("message", "删除员工成功"); if(backurl != null && backurl.indexOf("shanchuyuangong.action") == -1){ return "forward:/" + backurl; } return "forward:/yuangongguanli.action"; } // 定义sousuoyuangong方法,处理搜索操作 @RequestMapping(value = "sousuoyuangong") public String sousuoyuangong(HttpServletRequest request, HttpServletResponse response,HttpSession session,String search,String backurl) { logger.debug("YuangongController.sousuoyuangong ......"); YuangongExample example = new YuangongExample(); YuangongExample.Criteria criteria = example.createCriteria(); if(search != null){ criteria.andMingziLike("%" + search + "%"); } List yuangongall = yuangongdao.selectByExample(example); request.setAttribute("yuangongall", yuangongall); if(backurl != null && backurl.indexOf("sousuoyuangong.action") == -1){ return "forward:/" + backurl; } return "sousuoyuangong"; } // 定义YuangongpinglunMapper@RequestMapping (value = "yuangongxiangqing") public String yuangongxiangqing(HttpServletRequest request,HttpSession session, HttpServletResponse response,int id,String backurl) {logger. debug("YuangongController.yuangongxiangqing ......");Yuangong yuangong = yuangongdao.selectByPrimaryKey(id);request. setAttribute("yuangong", yuangong); if(backurl != null && backurl.indexOf("yuangongxiangqing.action") == -1){ return "forward:/" + backurl; } return "yuangongxiangqing"; } // 上传文件图片等 public String uploadUtile(MultipartFile file, HttpServletRequest request) throws IOException { // 根据当前时间生成时间字符串 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSS"); String res = sdf.format(new Date()); // uploads文件夹位置 String rootPath = request.getSession().getServletContext().getRealPath("resource/uploads/"); // 原始名称 String originalFileName = file.getOriginalFilename(); // 新文件名 String newFileName = "sliver" + res + originalFileName.substring(originalFileName.lastIndexOf(".")); // 创建年月文件夹 Calendar date = Calendar.getInstance(); File dateDirs = new File(date.get(Calendar.YEAR) + File.separator + (date.get(Calendar.MONTH)+1)); // 新文件 File newFile = new File(rootPath + File.separator + dateDirs + File.separator + newFileName); // 判断目标文件所在目录是否存在 if( !newFile.getParentFile().exists()) { // 如果目标文件所在的目录不存在,则创建父目录newFile. getParentFile().mkdirs(); } System.out.println(newFile); // 将内存中的数据写入磁盘file. transferTo(newFile); // 完整的url String fileUrl = date.get(Calendar.YEAR) + "/" + (date.get(Calendar.MONTH)+1) + "/" + newFileName; return fileUrl; }}
标签:php servlet factor efault ase myeclipse 针对 管理员 www
原文地址:https://www.cnblogs.com/qwcx/p/11520818.html