基于javaweb的SSM员工管理系统员工考勤薪资管理(java+ssm+html+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

062223022309

072223022309

082223022309

092223022309

102223022309

112223022309

基于javaweb的SSM员工管理系统员工考勤薪资管理(java+ssm+html+mysql)

登录:
admin 123456

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

// 按主键查询管理员数据
@GetMapping(value = "getAdminById.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Admin getAdminById(String id) {
Admin admin = this.adminService.getAdminById(id);
return admin;
}

}




@RestController // 定义为控制器 返回JSON类型数据
@RequestMapping(value = "/salary", produces = "application/json; charset=utf-8") // 设置请求路径
@CrossOrigin // 允许跨域访问其资源
public class SalaryController extends BaseController {

@Autowired // @Autowired的作用是自动注入依赖的ServiceBean
private SalaryService salaryService;

// 预处理 获取基础参数
@GetMapping(value = "createSalary.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> createSalary() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("sno", "S" + VeDate.getStringDatex());
return map;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	employ.setXueli(obj.getString("xueli")); // 为学历赋值
employ.setGraduate(obj.getString("graduate")); // 为毕业院校赋值
employ.setWorkdate(obj.getString("workdate")); // 为入职日期赋值
employ.setMemo(obj.getString("memo")); // 为备注赋值
int num = this.employService.insertEmploy(employ);
if (num > 0) {
map.put("success", true);
map.put("code", num);
map.put("message", "保存成功");
} else {
map.put("success", false);
map.put("code", num);
map.put("message", "保存失败");
}
return map;
}

// 按主键删除一个员工
@GetMapping(value = "deleteEmploy.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> deleteEmploy(String id) {
Map<String, Object> map = new HashMap<String, Object>();
int num = this.employService.deleteEmploy(id);
if (num > 0) {
map.put("success", true);
map.put("code", num);
map.put("message", "删除成功");
} else {
map.put("success", false);
map.put("code", num);
map.put("message", "删除失败");
}
return map;
}

// 按主键批量删除员工
@PostMapping(value = "deleteEmployByIds.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> deleteEmployByIds(@RequestBody String[] ids) {
int num = 0;
for (String employid : ids) {
num += this.employService.deleteEmploy(employid);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
}

/*
* 获得颜色
*/
private Color getRandColor(int fc, int bc) {
if (fc > 255)
fc = 255;
if (bc > 255)
bc = 255;
int r = fc + random.nextInt(bc - fc - 16);
int g = fc + random.nextInt(bc - fc - 14);
int b = fc + random.nextInt(bc - fc - 18);
return new Color(r, g, b);
}

/**
* 生成随机图片
*/
public void getRandcode(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
// BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
g.fillRect(0, 0, width, height);
g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18));
g.setColor(getRandColor(110, 133));
// 绘制干扰线
for (int i = 0; i <= lineSize; i++) {
drowLine(g);
}
// 绘制随机字符
String randomString = "";
for (int i = 1; i <= stringNum; i++) {
randomString = drowString(g, randomString, i);
}
// 将生成的随机字符串保存到session中,而jsp界面通过session.getAttribute("RANDOMCODEKEY"),
// 获得生成的验证码,然后跟用户输入的进行比较
session.removeAttribute(RANDOMCODEKEY);
session.setAttribute(RANDOMCODEKEY, randomString);
g.dispose();
try {
// 将内存中的图片通过流动形式输出到客户端
ImageIO.write(image, "JPEG", response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}

/*
* 绘制字符串
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
		num += this.adminService.deleteAdmin(adminid);
}
Map<String, Object> map = new HashMap<String, Object>();
if (num > 0) {
map.put("success", true);
map.put("code", num);
map.put("message", "删除成功");
} else {
map.put("success", false);
map.put("code", num);
map.put("message", "删除失败");
}
return map;
}

// 修改管理员
@PostMapping(value = "updateAdmin.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> updateAdmin(@RequestBody String jsonStr) {
JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object
Admin admin = this.adminService.getAdminById(obj.getString("adminid")); // 获取object中adminid字段
admin.setUsername(obj.getString("username")); // 为用户名赋值
admin.setRealname(obj.getString("realname")); // 为姓名赋值
admin.setContact(obj.getString("contact")); // 为联系方式赋值

Map<String, Object> map = new HashMap<String, Object>();
int num = this.adminService.updateAdmin(admin);
if (num > 0) {
map.put("success", true);
map.put("code", num);
map.put("message", "修改成功");
} else {
map.put("success", false);
map.put("code", num);
map.put("message", "修改失败");
}
return map;
}

// 查询全部管理员数据 在下拉菜单中显示
@GetMapping(value = "getAllAdmin.action")
@ResponseBody // 将java对象转为json格式的数据返回
public List<Admin> getAllAdmin() {
return this.adminService.getAllAdmin();
}

// 通过AJAX在表格中显示管理员数据
@GetMapping(value = "getAdminByPage.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> getAdminByPage(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
// 定义一个Map对象 用来返回数据
Map<String, Object> map = new HashMap<String, Object>();
Page<Admin> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
		map.put("success", true);
map.put("code", num);
map.put("message", "删除成功");
} else {
map.put("success", false);
map.put("code", num);
map.put("message", "删除失败");
}
return map;
}

// 修改员工培训
@PostMapping(value = "updateTrains.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> updateTrains(@RequestBody String jsonStr) {
JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object
Trains trains = this.trainsService.getTrainsById(obj.getString("trainsid")); // 获取object中trainsid字段
trains.setEmployid(obj.getString("employid")); // 为员工赋值
trains.setItemx(obj.getString("itemx")); // 为培训项目赋值
trains.setIswork(obj.getString("iswork")); // 为是否脱产赋值
trains.setThestart(obj.getString("thestart")); // 为开始日期赋值
trains.setTheend(obj.getString("theend")); // 为结束日期赋值
trains.setMemo(obj.getString("memo")); // 为备注赋值

Map<String, Object> map = new HashMap<String, Object>();
int num = this.trainsService.updateTrains(trains);
if (num > 0) {
map.put("success", true);
map.put("code", num);
map.put("message", "修改成功");
} else {
map.put("success", false);
map.put("code", num);
map.put("message", "修改失败");
}
return map;
}

// 查询全部员工培训数据 在下拉菜单中显示
@GetMapping(value = "getAllTrains.action")
@ResponseBody // 将java对象转为json格式的数据返回
public List<Trains> getAllTrains() {
return this.trainsService.getAllTrains();
}

// 通过AJAX在表格中显示员工培训数据
@GetMapping(value = "getTrainsByPage.action")
@ResponseBody // 将java对象转为json格式的数据返回
public Map<String, Object> getTrainsByPage(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
// 定义一个Map对象 用来返回数据
Map<String, Object> map = new HashMap<String, Object>();


项目链接:
https://javayms.github.io?id=052223022309201fk
https://javayms.pages.dev?id=052223022309201fk