基于javaweb+mysql的ssm+mavenoa办公管理系统(java+layui+ssm+maven+mysql+jsp)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Mavenoa办公管理系统(java+layui+ssm+maven+mysql+jsp)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
@Override
public JSONObject applyForOfficeSupplies(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String stationeryProposerStr = request.getParameter("stationeryProposer");
String employeeNumber = SecurityUtils.getSubject().getPrincipal().toString(); //得到自身工号
if (stationeryProposerStr == null || employeeNumber == null) {
json.put("type", "error");
json.put("msg", "获取数据失败!");
return json;
}
/**
* 获得StationeryProposer实体类
*/
StationeryProposer stationeryProposer = JSONObject.parseObject(stationeryProposerStr, StationeryProposer.class);
/**
* 设置审批人ID
*/
stationeryProposer.setApproveEmployeeId(stationeryDao.selectEmployeeIdByDepartmentHeadId(DepartmentHead.DepartmentAdministrative));
/**
* 保存到数据库
*/
if (stationeryDao.applicationForOfficeSupplies(stationeryProposer, employeeNumber) > 0) {
//如果大于0|成功
json.put("type", "success");
json.put("msg", "申请成功,请等待审批!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "申请失败!");
return json;
}
@Override
public JSONObject addStationery(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String stationeryStr = request.getParameter("stationery");
if (stationeryStr == null) {
json.put("type", "error");
json.put("msg", "获取数据成功!");
json.put("data", punches);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
@Override
public JSONObject punchingCardRecordAll(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
int page;
int limit;
List<Punch> punches;
String pageStr = request.getParameter("page");
String limitStr = request.getParameter("limit");
String employeeNumberStr = request.getParameter("employeeNumber");
String startDateStr = request.getParameter("startDate");
String endDateStr = request.getParameter("endDate");
if (pageStr == null || limitStr == null) {
json.put("type", "error");
json.put("msg", "获取表格数据失败");
System.out.println("数据为空!");
return json;
}
page = Integer.parseInt(pageStr); //转成int类型
limit = Integer.parseInt(limitStr);
if ((employeeNumberStr == null || "".equals(employeeNumberStr)) && (startDateStr == null || "".equals(startDateStr)) && (endDateStr == null || "".equals(endDateStr))) {
punches = punchDao.selectPunchByEmployeeNumber(null, (page - 1) * limit, limit, null, null);
json.put("count", punchDao.selectPunchCount(null,null,null));
} else {
punches = punchDao.selectPunchByEmployeeNumber(employeeNumberStr, (page - 1) * limit, limit, startDateStr, endDateStr);
json.put("count", punchDao.selectPunchCount(employeeNumberStr,startDateStr,endDateStr));
}
json.put("type", "success");
json.put("msg", "获取数据成功");
json.put("code", 0);
json.put("data", punches);
} catch (Exception e) {
SimpleDateFormat formatLeading = new SimpleDateFormat("yyyy-MM-dd");
//得到打卡时段
String currentClock = format.format(new Date()); //得到当前打卡的时间
String businessHours = formatLeading.format(new Date()) + " " + PunchConstant.BUSINESS_HOURS; //得到上班的打卡时间段
String closingTime = formatLeading.format(new Date()) + " " + PunchConstant.CLOSING_TIME; //得到下班的打卡时间段
//判断打卡类型和打卡时间是否符合
if (punchClassify == null) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println("punchClassify数据为空");
return json;
} else if (punchClassify.equals("1")) {
//如果是上班打卡
punchClassifyInt = 1;
Date parse = format.parse(currentClock); //转为date型
Date parse1 = format.parse(businessHours);
if (parse.before(parse1)) {
//如果上班时间早于当前时间
json.put("type", "error");
json.put("msg", "还没到上班打卡时间!");
return json;
}
} else if (punchClassify.equals("2")) {
//如果是下班打卡
punchClassifyInt = 2;
Date parse = format.parse(currentClock); //转为date型
Date parse1 = format.parse(closingTime);
if (parse.before(parse1)) {
//如果下班时间不早于当前时间
json.put("type", "error");
json.put("msg", "还没到下班打卡时间!");
return json;
}
}
//判断今天是否打过卡
if (punchDao.selectEmployeePunchByNumber(employeeNumber, punchClassifyInt, formatLeading.format(new Date())) != null) {
//如果打过卡
String str = "上班签到";
if (punchClassifyInt == 2) str = "下班签退";
json.put("type", "error");
json.put("msg", "今天已经打过" + str + "卡了!");
return json;
}
//保存打卡记录
Punch punch = new Punch();
punch.setEmployeeId(punchDao.selectEmployeeIdByNumber(employeeNumber));
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "添加菜单失败!");
return json;
}
/**
* 修改菜单
*
* @param request
* @return
*/
@RequestMapping("/updateMenu")
@ResponseBody
public JSONObject updateMenu(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
Menu menu = JSONObject.parseObject(request.getParameter("menu"), Menu.class);
if (menuService.updateMenu(menu) > 0) {
json.put("type", "success");
json.put("msg", "修改菜单成功!");
return json;
}
} catch (Exception e) {
json.put("tpe", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "修改菜单失败!");
return json;
}
/**
* 删除菜单
*
* @param request
* @return
*/
@RequestMapping("/deleteMenu")
@ResponseBody
public JSONObject deleteMenu(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
int menuId = Integer.parseInt(request.getParameter("menuId"));
Department department = JSONObject.parseObject(request.getParameter("department"), Department.class);
if(departmentService.verifyDepartmentTitle(department) > 0){
json.put("type","error");
json.put("msg","部门名称重复,请使用别的部门名称");
return json;
}
if(departmentService.updateDepartment(department) > 0){
json.put("type","success");
json.put("msg","修改成功");
return json;
}
}catch (Exception e){
json.put("type","success");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
}
return json;
}
/**
* 删除部门
* @param request
* @return
*/
@RequestMapping("/deleteDepartment")
@ResponseBody
public JSONObject deleteDepartment(HttpServletRequest request){
JSONObject json = new JSONObject();
try{
String departmentId = request.getParameter("departmentId");
if(departmentService.verifyDepartmentByEmployee(Integer.parseInt(departmentId)) > 0){
json.put("type","error");
json.put("msg","该部门还含有雇员存在,无法删除");
return json;
}
if(departmentService.deleteDepartment(Integer.parseInt(departmentId)) > 0){
json.put("type","success");
json.put("msg","删除成功");
return json;
}
}catch (Exception e){
json.put("type","success");
json.put("msg",MessageError.SYSTEM_ERROR);
if (employeeDao.verifyEmployeePhone(employee) > 0) {
json.put("type", "error");
json.put("msg", "该手机号已被使用,请使用别的手机号");
return json;
}
/**
* 对密码进行加密
*/
String hashAlgorithmName = "MD5";//加密
String credentials = "123456";//密码
int hashIterations = 1024; //加密次数
ByteSource bytes = ByteSource.Util.bytes(employee.getEmployeeName());//盐值
Object obj = new SimpleHash(hashAlgorithmName, credentials, bytes, hashIterations);
System.out.println(obj);
employee.setEmployeePassword(obj.toString());
if (employeeDao.addEmployee(employee) > 0) {
json.put("type", "success");
json.put("msg", "添加雇员成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "添加雇员失败");
return json;
}
@Override
public JSONObject updateEmployee(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
Employee employee = JSONObject.parseObject(request.getParameter("employee"), Employee.class);
if (employeeDao.verifyEmployeeNumber(employee) > 0) {
json.put("type", "error");
json.put("msg", "该工号已被使用,请使用别的工号");
return json;
}
if (employeeDao.verifyEmployeePhone(employee) > 0) {
json.put("type", "error");
json.put("msg", "该手机号已被使用,请使用别的手机号");
return json;
}
if (employeeDao.updateEmployeeAdmin(employee) > 0) {
json.put("type", "success");
json.put("msg", "修改雇员成功");
return noticeService.bulkReleaseNotice(request);
}
/**
* 查看已发布公告
* @param request
* @return
*/
@RequestMapping("/publishedAnnouncements")
@ResponseBody
public JSONObject publishedAnnouncements(HttpServletRequest request){
return noticeService.publishedAnnouncements(request);
}
/**
* 撤销发布的系统公告
* @param request
* @return
*/
@RequestMapping("/revocation")
@ResponseBody
public JSONObject revocation(HttpServletRequest request){
return noticeService.revocation(request);
}
/**
* 打开系统弹出最新的系统消息
* @param request
* @return
*/
@RequestMapping("/queryingSystemMessages")
@ResponseBody
public JSONObject queryingSystemMessages(HttpServletRequest request){
return noticeService.queryingSystemMessages(request);
}
/**
* 点击已阅读
* @param request
* @return
*/
@RequestMapping("/noticeRead")
@ResponseBody
public JSONObject noticeRead(HttpServletRequest request){
return noticeService.noticeRead(request);
}
}
JSONObject json = new JSONObject();
try {
int page; //页码
int limit; //每页数据量
//获取数据
String pageStr = request.getParameter("page");
String limitStr = request.getParameter("limit");
String employeeNumber = SecurityUtils.getSubject().getPrincipal().toString(); //得到自身工号
//校验数据是否为空
if (pageStr == null || limitStr == null) {
//为空
json.put("type", "error");
json.put("msg", "数据获取错误!");
return json;
}
//转成int型
page = Integer.parseInt(pageStr);
limit = Integer.parseInt(limitStr);
//查询
List<Notice> notices = noticeDao.selectNoticeAll((page - 1) * limit, limit);
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", notices.size());
json.put("data", notices);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
@Override
public JSONObject addNotice(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
//从前端接收数据
String noticeStr = request.getParameter("notice");
if (noticeStr == null) {
json.put("type", "error");
json.put("msg", "接收数据为空!");
return json;
}
Notice notice = JSONObject.parseObject(noticeStr, Notice.class);
@Override
public JSONObject stationeryApproverMarkHistory(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
int page;
int limit;
String pageStr = request.getParameter("page");
String limitStr = request.getParameter("limit");
if (pageStr == null || limitStr == null) {
json.put("type", "error");
json.put("msg", "获取数据失败!");
return json;
}
page = Integer.parseInt(pageStr);
limit = Integer.parseInt(limitStr);
List<StationeryProposer> stationeryProposers = stationeryDao.selectStationeryApproverMarkHistory( (page - 1) * limit, limit);
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", stationeryDao.selectStationeryApproverMarkHistoryCount());
json.put("data", stationeryProposers);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
}
Employee employee = JSONObject.parseObject(request.getParameter("employee"), Employee.class);
if (employeeDao.verifyEmployeeNumber(employee) > 0) {
json.put("type", "error");
json.put("msg", "该工号已被使用,请使用别的工号");
return json;
}
if (employeeDao.verifyEmployeePhone(employee) > 0) {
json.put("type", "error");
json.put("msg", "该手机号已被使用,请使用别的手机号");
return json;
}
/**
* 对密码进行加密
*/
String hashAlgorithmName = "MD5";//加密
String credentials = "123456";//密码
int hashIterations = 1024; //加密次数
ByteSource bytes = ByteSource.Util.bytes(employee.getEmployeeName());//盐值
Object obj = new SimpleHash(hashAlgorithmName, credentials, bytes, hashIterations);
System.out.println(obj);
employee.setEmployeePassword(obj.toString());
if (employeeDao.addEmployee(employee) > 0) {
json.put("type", "success");
json.put("msg", "添加雇员成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "添加雇员失败");
return json;
}
@Override
public JSONObject updateEmployee(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
Employee employee = JSONObject.parseObject(request.getParameter("employee"), Employee.class);
if (employeeDao.verifyEmployeeNumber(employee) > 0) {
json.put("type", "error");
json.put("msg", "该工号已被使用,请使用别的工号");
return json;
}
if (employeeDao.verifyEmployeePhone(employee) > 0) {
json.put("type", "error");
if(menu.getPid().equals(-1)){
List<Menu> menuList1 = new ArrayList<>();
for(Menu menu1 : menuAll){
if(menu.getId().equals(menu1.getPid())){
menuList1.add(menu1);
}
}
if(menuList1.size() > 0){
menu.setChildren(menuList1);
}
menuList.add(menu);
}
}
return menuList;
}
}
@Transactional
@Service("/permissionsService")
public class PermissionsServiceImpl implements PermissionsService {
@Autowired
private PermissionsDao permissionsDao;
@Override
public JSONObject getPermissionsAll(HttpServletRequest request) {
JSONObject json = new JSONObject();
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
List<Permissions> permissions = permissionsDao.selectPermissionsAll((page - 1) * limit, limit);
json.put("code", 0);
json.put("msg", "");
json.put("count", permissionsDao.selectPermissionsAllCount());
json.put("data", permissions);
json.put("msg", "null");
return json;
}
Integer[] employeeIdLists = JSONObject.parseObject(employeeIdList, Integer[].class);
if (employeeDao.batchUpdateEmployeeByRoleId(employeeIdLists, Integer.parseInt(roleId)) > 0) {
json.put("type", "success");
json.put("msg", "修改角色成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "修改角色失败!");
return json;
}
@Override
public JSONObject updateDepartment(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String employeeIdList = request.getParameter("employeeIdList");
String departmentId = request.getParameter("departmentId");
if (employeeIdList == null || departmentId == null) {
json.put("type", "error");
json.put("msg", "null");
return json;
}
Integer[] employeeIdLists = JSONObject.parseObject(employeeIdList, Integer[].class);
if (employeeDao.batchUpdateEmployeeByDepartmentId(employeeIdLists, Integer.parseInt(departmentId)) > 0) {
json.put("type", "success");
json.put("msg", "修改部门成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
for (Integer i : permissionsId) {
if (permissions.getPermissionsId().equals(i)) {
menu.setSpread(true); //展开
menu.setChecked(true); //选中
for (Permissions permissions1 : permissionsList) {
if (permissions.getPermissionsId().equals(permissions1.getPermissionsPid())) {
menu.setChecked(false); //不选中
}
}
}
}
menuList1.add(menu);
}
//整理成树型
for (Menu menu : menuList1) {
if (menu.getPid().equals(-1)) {
List<Menu> menuList2 = new ArrayList<>();
for (Menu menu1 : menuList1) {
if (menu.getId().equals(menu1.getPid())) {
menuList2.add(menu1);
}
}
if (menuList2.size() > 0) menu.setChildren(menuList2);
menuList.add(menu);
}
}
return menuList;
}
}
@Controller
@RequestMapping("/role")
@RequestMapping("/deleteDepartment")
@ResponseBody
public JSONObject deleteDepartment(HttpServletRequest request){
JSONObject json = new JSONObject();
try{
String departmentId = request.getParameter("departmentId");
if(departmentService.verifyDepartmentByEmployee(Integer.parseInt(departmentId)) > 0){
json.put("type","error");
json.put("msg","该部门还含有雇员存在,无法删除");
return json;
}
if(departmentService.deleteDepartment(Integer.parseInt(departmentId)) > 0){
json.put("type","success");
json.put("msg","删除成功");
return json;
}
}catch (Exception e){
json.put("type","success");
json.put("msg",MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
}
return json;
}
@RequestMapping("/updateDepartmentPrincipal")
@ResponseBody
public JSONObject updateDepartmentPrincipal(HttpServletRequest request){
return departmentService.updateDepartmentPrincipal(request);
}
}
@RequestMapping("/stationery")
@Controller
public class StationeryController {
@Autowired
private StationeryService stationeryService;
/**
* 获取办公用品全部信息
*
}
noticeId = Integer.parseInt(noticeIdStr);
if (noticeDao.revocation(noticeId) > 0) {
json.put("type", "success");
json.put("msg", "撤销系统公告成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "撤销系统公告失败!");
return json;
}
@Override
public JSONObject queryingSystemMessages(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String employeeNumber = SecurityUtils.getSubject().getPrincipal().toString(); //得到自身工号
if (employeeNumber == null) {
json.put("type", "error");
json.put("msg", "获取数据失败!");
return json;
}
List<Notice> notices = noticeDao.queryingSystemMessages(employeeNumber);
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", notices.size());
json.put("data", notices);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
/**
* 删除办公用品
*
* @param request
* @return
*/
@RequestMapping("/deleteStationery")
@ResponseBody
public JSONObject deleteStationery(HttpServletRequest request) {
return stationeryService.deleteStationery(request);
}
/**
* 添加新办公用品数量
*
* @param request
* @return
*/
@RequestMapping("/addStationeryAdd")
@ResponseBody
public JSONObject addStationeryAdd(HttpServletRequest request) {
return stationeryService.addStationeryAdd(request);
}
/**
* 获取添加新办公用品数量历史信息
*
* @param request
* @return
*/
@RequestMapping("/getStationeryAddHistory")
@ResponseBody
public JSONObject getStationeryAddHistory(HttpServletRequest request) {
return stationeryService.getStationeryAddHistory(request);
}
/**
* 申请使用办公用品
*
* @param request
* @return
*/
@RequestMapping("/applyForOfficeSupplies")
@ResponseBody
public JSONObject applyForOfficeSupplies(HttpServletRequest request) {
return stationeryService.applyForOfficeSupplies(request);
}
/**
public JSONObject getStationeryApprovalInformation(HttpServletRequest request){
return stationeryService.getStationeryApprovalInformation(request);
}
/**
* 申请办公用品审批
* @param request
* @return
*/
@RequestMapping("/stationeryApproverMark")
@ResponseBody
public JSONObject stationeryApproverMark(HttpServletRequest request){
return stationeryService.stationeryApproverMark(request);
}
/**
* 申请办公用品审批历史
* @param request
* @return
*/
@RequestMapping("/stationeryApproverMarkHistory")
@ResponseBody
public JSONObject stationeryApproverMarkHistory(HttpServletRequest request){
return stationeryService.stationeryApproverMarkHistory(request);
}
}
@Controller