UserServiceImp.java
3.42 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.example.dahua.service;
import com.example.dahua.async.SendUserInfoTask;
import com.example.dahua.bean.AttendanceBean;
import com.example.dahua.bean.TeacherBean;
import com.example.dahua.bean.UserInfoBean;
import com.example.dahua.dao.UserDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import java.util.List;
@Repository
@Service
public class UserServiceImp implements UserService {
@Autowired
UserDao userDao;
@Autowired
SendUserInfoTask myTask;
@Override
public List<AttendanceBean> getAttendanceBeans(String schoolId, String clint_type, String devid) {
if (!StringUtils.isEmpty(devid)) return userDao.getAttendanceBeanWithId(schoolId, clint_type, devid);
return userDao.getAttendanceBeans(schoolId, clint_type);
}
@Override
public UserInfoBean getUserInfo(String schoolId, String studentCode) {
return userDao.getUserInfo(schoolId, studentCode);
}
/**
* 单个用户信息下发
*
* @param file
* @param schoolId
* @param studentCode
* @param clint_type
* @return
*/
@Override
public boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType, String devid) {
List<AttendanceBean> attendanceBeans = getAttendanceBeans(schoolId, clint_type, devid);//获取学校下的大华设备
System.out.println("设备数量:" + attendanceBeans.size());
UserInfoBean userInfoBean = null;
try {
if (userType == 2) {
//根据文件命名来判断学籍号
String studentCodes = file.split("\\.")[0];
String[] studentInfo = studentCodes.split("_");
if (studentInfo.length > 1) {//附属卡
String studentCodeF = studentInfo[0];
String CardType = studentInfo[1];
userInfoBean = getUserInfo(schoolId, studentCodeF);
String cardNum = userDao.getCardNum(userInfoBean.getStudent_id(), CardType);
userInfoBean.setStudent_num(cardNum);
} else {
userInfoBean = getUserInfo(schoolId, studentCode);//获取用户信息
}
} else if (userType == 1) {
TeacherBean teacher = userDao.getTeacher(schoolId, studentCode);
if (null != teacher) {
userInfoBean = new UserInfoBean();
userInfoBean.setStudent_num(teacher.getTeacher_num());
userInfoBean.setName(teacher.getName());
userInfoBean.setUser_id(teacher.getUser_id());
userInfoBean.setStudentcode(teacher.getNum());
userInfoBean.setStudent_id(teacher.getTeacher_id());
}
}
myTask.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
/**
* 照片下放
*
* @param schoolId
* @param clint_type
* @param type 0:主卡 1:副卡
*/
@Override
public void sendUserInfos(String schoolId, String clint_type, int type) {
myTask.doTaskSendUserInfos(schoolId, clint_type, type, -1);
}
}