基於SSM開發的企業人事管理系統

不愛吃胡蘿蔔的小黑兔發表於2020-11-12

10120 基於SSM開發的企業人事管理系統

執行視訊、程式碼等:
鏈-椄:https://pan@baidu@com/s/1tw4Qvtcuwt7ys36M7HvLSg(把@換成 . 就可正常訪問)
趧-紶-碼:1589
f/u枝此段-吶傛開啟baidu網盤手機App,caozuo更方便哦

技術
Spring + SpringMVC+ MyBatis

工具
eclipse + tomact + mysql + jdk

功能詳情

  • 使用者管理
  • 職位管理
  • 部門管理
  • 員工管理
  • 公告管理
  • 下載中心
  • 系統設定

系統相關截圖

在這裡插入圖片描述
package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.JobLevelMapper;
import org.javaboy.vhr.model.JobLevel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class JobLevelService {
@Autowired
JobLevelMapper jobLevelMapper;

public List<JobLevel> getAllJobLevels() {
    return jobLevelMapper.getAllJobLevels();
}

public Integer addJobLevel(JobLevel jobLevel) {
    jobLevel.setCreateDate(new Date());
    jobLevel.setEnabled(true);
    return jobLevelMapper.insertSelective(jobLevel);
}

public Integer updateJobLevelById(JobLevel jobLevel) {
    return jobLevelMapper.updateByPrimaryKeySelective(jobLevel);
}

public Integer deleteJobLevelById(Integer id) {
    return jobLevelMapper.deleteByPrimaryKey(id);
}

public Integer deleteJobLevelsByIds(Integer[] ids) {
    return jobLevelMapper.deleteJobLevelsByIds(ids);
}

}

package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.MailSendLogMapper;
import org.javaboy.vhr.model.MailSendLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MailSendLogService {
@Autowired
MailSendLogMapper mailSendLogMapper;
public Integer updateMailSendLogStatus(String msgId, Integer status) {
return mailSendLogMapper.updateMailSendLogStatus(msgId, status);
}

public Integer insert(MailSendLog mailSendLog) {
    return mailSendLogMapper.insert(mailSendLog);
}

public List<MailSendLog> getMailSendLogsByStatus() {
    return mailSendLogMapper.getMailSendLogsByStatus();
}

public Integer updateCount(String msgId, Date date) {
    return mailSendLogMapper.updateCount(msgId,date);
}

}
package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.SalaryMapper;
import org.javaboy.vhr.model.Salary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SalaryService {
@Autowired
SalaryMapper salaryMapper;

public List<Salary> getAllSalaries() {
    return salaryMapper.getAllSalaries();
}

public Integer addSalary(Salary salary) {
    salary.setCreateDate(new Date());
    return salaryMapper.insertSelective(salary);
}

public Integer deleteSalaryById(Integer id) {
    return salaryMapper.deleteByPrimaryKey(id);
}

public Integer updateSalaryById(Salary salary) {
    return salaryMapper.updateByPrimaryKeySelective(salary);
}

}package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.HrMapper;
import org.javaboy.vhr.mapper.HrRoleMapper;
import org.javaboy.vhr.model.Hr;
import org.javaboy.vhr.utils.HrUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HrService implements UserDetailsService {
@Autowired
HrMapper hrMapper;
@Autowired
HrRoleMapper hrRoleMapper;

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    Hr hr = hrMapper.loadUserByUsername(username);
    if (hr == null) {
        throw new UsernameNotFoundException("使用者名稱不存在!");
    }
    hr.setRoles(hrMapper.getHrRolesById(hr.getId()));
    return hr;
}

public List<Hr> getAllHrs(String keywords) {
    return hrMapper.getAllHrs(HrUtils.getCurrentHr().getId(),keywords);
}

public Integer updateHr(Hr hr) {
    return hrMapper.updateByPrimaryKeySelective(hr);
}

@Transactional
public boolean updateHrRole(Integer hrid, Integer[] rids) {
    hrRoleMapper.deleteByHrid(hrid);
    return hrRoleMapper.addRole(hrid, rids) == rids.length;
}

public Integer deleteHrById(Integer id) {
    return hrMapper.deleteByPrimaryKey(id);
}

public List<Hr> getAllHrsExceptCurrentHr() {
    return hrMapper.getAllHrsExceptCurrentHr(HrUtils.getCurrentHr().getId());
}

public Integer updateHyById(Hr hr) {
    return hrMapper.updateByPrimaryKeySelective(hr);
}

public boolean updateHrPasswd(String oldpass, String pass, Integer hrid) {
    Hr hr = hrMapper.selectByPrimaryKey(hrid);
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
    if (encoder.matches(oldpass, hr.getPassword())) {
        String encodePass = encoder.encode(pass);
        Integer result = hrMapper.updatePasswd(hrid, encodePass);
        if (result == 1) {
            return true;
        }
    }
    return false;
}

public Integer updateUserface(String url, Integer id) {
    return hrMapper.updateUserface(url, id);
}

}package org.javaboy.vhr.task;

import org.javaboy.vhr.model.Employee;
import org.javaboy.vhr.model.MailConstants;
import org.javaboy.vhr.model.MailSendLog;
import org.javaboy.vhr.service.EmployeeService;
import org.javaboy.vhr.service.MailSendLogService;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
public class MailSendTask {
@Autowired
MailSendLogService mailSendLogService;
@Autowired
RabbitTemplate rabbitTemplate;
@Autowired
EmployeeService employeeService;
@Scheduled(cron = “0/10 * * * * ?”)
public void mailResendTask() {
List logs = mailSendLogService.getMailSendLogsByStatus();
if (logs == null || logs.size() == 0) {
return;
}
logs.forEach(mailSendLog->{
if (mailSendLog.getCount() >= 3) {
mailSendLogService.updateMailSendLogStatus(mailSendLog.getMsgId(), 2);//直接設定該條訊息傳送失敗
}else{
mailSendLogService.updateCount(mailSendLog.getMsgId(), new Date());
Employee emp = employeeService.getEmployeeById(mailSendLog.getEmpId());
rabbitTemplate.convertAndSend(MailConstants.MAIL_EXCHANGE_NAME, MailConstants.MAIL_ROUTING_KEY_NAME, emp, new CorrelationData(mailSendLog.getMsgId()));
}
});
}
}

相關文章