Commit acd712a65d52689f4378d7958eeb83c874f6db8e
1 parent
a2a3d070
Exists in
master
增加网关负载
Showing
51 changed files
with
2386 additions
and
1073 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
1 | 1 | package com.example.dahua; |
2 | 2 | |
3 | -import com.example.dahua.Gate.Gate; | |
4 | -import com.example.dahua.alarmListen.AlarmListenModule; | |
5 | 3 | import com.example.dahua.bean.CardBean; |
6 | 4 | import com.example.dahua.bean.DeviceInfoBean; |
7 | 5 | import com.example.dahua.bean.TeacherBean; |
... | ... | @@ -14,9 +12,7 @@ import com.example.dahua.module.AutoRegisterModule; |
14 | 12 | import com.example.dahua.module.GateModule; |
15 | 13 | import com.example.dahua.module.LoginModule; |
16 | 14 | import com.example.dahua.service.AttendanceService; |
17 | -import com.example.dahua.utils.FileUtils; | |
18 | 15 | import com.example.dahua.xiananDao.SendRecordDao; |
19 | -import com.sun.jna.NativeLong; | |
20 | 16 | import com.sun.jna.Pointer; |
21 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
22 | 18 | import org.springframework.boot.ApplicationArguments; |
... | ... | @@ -25,7 +21,6 @@ import org.springframework.stereotype.Component; |
25 | 21 | import org.springframework.util.StringUtils; |
26 | 22 | |
27 | 23 | import javax.imageio.ImageIO; |
28 | -import java.awt.*; | |
29 | 24 | import java.awt.image.BufferedImage; |
30 | 25 | import java.io.ByteArrayInputStream; |
31 | 26 | import java.io.File; | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java
... | ... | @@ -190,7 +190,7 @@ public class MyScheduledTask { |
190 | 190 | File file = new File(filePath); |
191 | 191 | try { |
192 | 192 | if (!file.exists()) { |
193 | - System.out.println("文件不存在:" + filePath); | |
193 | +// System.out.println("文件不存在:" + filePath); | |
194 | 194 | return; |
195 | 195 | } |
196 | 196 | FileInputStream fileInputStream = new FileInputStream(file); | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/PermissionBean.java
1 | 1 | package com.example.dahua.bean; |
2 | 2 | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | + | |
3 | 5 | import java.io.Serializable; |
4 | 6 | import java.util.List; |
5 | 7 | |
6 | 8 | public class PermissionBean implements Serializable { |
7 | 9 | |
10 | + @ApiModelProperty(value = "设备id",required = true) | |
8 | 11 | private List<String> deviceIds; |
9 | 12 | |
10 | 13 | private List<WeekDay> weekDays; |
11 | 14 | |
15 | + @ApiModelProperty("用逗号隔开,1:通校生,2:住校生,3:全部") | |
16 | + private String studentType; | |
17 | + | |
18 | + public String getStudentType() { | |
19 | + return studentType; | |
20 | + } | |
21 | + | |
22 | + public void setStudentType(String studentType) { | |
23 | + this.studentType = studentType; | |
24 | + } | |
25 | + | |
12 | 26 | public List<String> getDeviceIds() { |
13 | 27 | return deviceIds; |
14 | 28 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/PermissionFaceBean.java
0 → 100644
... | ... | @@ -0,0 +1,108 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonInclude; | |
4 | +import io.swagger.annotations.ApiModelProperty; | |
5 | +import org.apache.ibatis.annotations.Result; | |
6 | + | |
7 | +import java.io.Serializable; | |
8 | + | |
9 | +/** | |
10 | + * 人脸设备权限表 | |
11 | + * create table PermissionFace ( | |
12 | + * id int not null PRIMARY KEY , | |
13 | + * permissionJSON varchar(max) not null , | |
14 | + * schoolId int not null , | |
15 | + * perrmissName varchar(50) not null , | |
16 | + * createTime varchar(50) not null , | |
17 | + * updateTime varchar(50) not null , | |
18 | + * ) | |
19 | + */ | |
20 | +@JsonInclude(JsonInclude.Include.NON_EMPTY) | |
21 | +public class PermissionFaceBean implements Serializable { | |
22 | + | |
23 | + @ApiModelProperty(value = "删除和编辑时需要传") | |
24 | + private int id; | |
25 | + | |
26 | + @ApiModelProperty(required = true) | |
27 | + private PermissionBean permissionBean; | |
28 | + | |
29 | + @ApiModelProperty(required = true) | |
30 | + private int schoolId; | |
31 | + | |
32 | + @ApiModelProperty(value = "权限模板名称",required = true) | |
33 | + private String perrmissName; | |
34 | + | |
35 | + private String createTime; | |
36 | + | |
37 | + private String updateTime; | |
38 | + | |
39 | + @ApiModelProperty(notes = "备用字段,不用传") | |
40 | + private String permissionJson; | |
41 | + | |
42 | + @ApiModelProperty(value = "0-新增;1-编辑;2-删除",required = true) | |
43 | + private int type; | |
44 | + | |
45 | + public int getType() { | |
46 | + return type; | |
47 | + } | |
48 | + | |
49 | + public void setType(int type) { | |
50 | + this.type = type; | |
51 | + } | |
52 | + | |
53 | + public int getId() { | |
54 | + return id; | |
55 | + } | |
56 | + | |
57 | + public void setId(int id) { | |
58 | + this.id = id; | |
59 | + } | |
60 | + | |
61 | + public PermissionBean getPermissionBean() { | |
62 | + return permissionBean; | |
63 | + } | |
64 | + | |
65 | + public void setPermissionBean(PermissionBean permissionBean) { | |
66 | + this.permissionBean = permissionBean; | |
67 | + } | |
68 | + | |
69 | + public int getSchoolId() { | |
70 | + return schoolId; | |
71 | + } | |
72 | + | |
73 | + public void setSchoolId(int schoolId) { | |
74 | + this.schoolId = schoolId; | |
75 | + } | |
76 | + | |
77 | + public String getPerrmissName() { | |
78 | + return perrmissName; | |
79 | + } | |
80 | + | |
81 | + public void setPerrmissName(String perrmissName) { | |
82 | + this.perrmissName = perrmissName; | |
83 | + } | |
84 | + | |
85 | + public String getCreateTime() { | |
86 | + return createTime; | |
87 | + } | |
88 | + | |
89 | + public void setCreateTime(String createTime) { | |
90 | + this.createTime = createTime; | |
91 | + } | |
92 | + | |
93 | + public String getUpdateTime() { | |
94 | + return updateTime; | |
95 | + } | |
96 | + | |
97 | + public void setUpdateTime(String updateTime) { | |
98 | + this.updateTime = updateTime; | |
99 | + } | |
100 | + | |
101 | + public String getPermissionJson() { | |
102 | + return permissionJson; | |
103 | + } | |
104 | + | |
105 | + public void setPermissionJson(String permissionJson) { | |
106 | + this.permissionJson = permissionJson; | |
107 | + } | |
108 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/PermissionHKBean.java
0 → 100644
... | ... | @@ -0,0 +1,48 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +/** | |
6 | + * 海康人脸请求参数 | |
7 | + */ | |
8 | +public class PermissionHKBean { | |
9 | + private List<String> deviceIds; | |
10 | + | |
11 | + private String schoolId; | |
12 | + | |
13 | + private String userType;//学生类型 | |
14 | + | |
15 | + private List<WeekDay> weekDays; | |
16 | + | |
17 | + public List<String> getDeviceIds() { | |
18 | + return deviceIds; | |
19 | + } | |
20 | + | |
21 | + public void setDeviceIds(List<String> deviceIds) { | |
22 | + this.deviceIds = deviceIds; | |
23 | + } | |
24 | + | |
25 | + public String getSchoolId() { | |
26 | + return schoolId; | |
27 | + } | |
28 | + | |
29 | + public void setSchoolId(String schoolId) { | |
30 | + this.schoolId = schoolId; | |
31 | + } | |
32 | + | |
33 | + public String getUserType() { | |
34 | + return userType; | |
35 | + } | |
36 | + | |
37 | + public void setUserType(String userType) { | |
38 | + this.userType = userType; | |
39 | + } | |
40 | + | |
41 | + public List<WeekDay> getWeekDays() { | |
42 | + return weekDays; | |
43 | + } | |
44 | + | |
45 | + public void setWeekDays(List<WeekDay> weekDays) { | |
46 | + this.weekDays = weekDays; | |
47 | + } | |
48 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/ResponseBean.java
0 → 100644
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +public class ResponseBean<T> { | |
4 | + | |
5 | + private int status; | |
6 | + | |
7 | + private String message; | |
8 | + | |
9 | + private T data; | |
10 | + | |
11 | + public int getStatus() { | |
12 | + return status; | |
13 | + } | |
14 | + | |
15 | + public void setStatus(int status) { | |
16 | + this.status = status; | |
17 | + } | |
18 | + | |
19 | + public String getMessage() { | |
20 | + return message; | |
21 | + } | |
22 | + | |
23 | + public void setMessage(String message) { | |
24 | + this.message = message; | |
25 | + } | |
26 | + | |
27 | + public T getData() { | |
28 | + return data; | |
29 | + } | |
30 | + | |
31 | + public void setData(T data) { | |
32 | + this.data = data; | |
33 | + } | |
34 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/ResponseBeanList.java
0 → 100644
... | ... | @@ -0,0 +1,37 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.List; | |
5 | + | |
6 | +public class ResponseBeanList<T> implements Serializable { | |
7 | + | |
8 | + private int status; | |
9 | + | |
10 | + private String message; | |
11 | + | |
12 | + private List<T> data; | |
13 | + | |
14 | + public int getStatus() { | |
15 | + return status; | |
16 | + } | |
17 | + | |
18 | + public void setStatus(int status) { | |
19 | + this.status = status; | |
20 | + } | |
21 | + | |
22 | + public String getMessage() { | |
23 | + return message; | |
24 | + } | |
25 | + | |
26 | + public void setMessage(String message) { | |
27 | + this.message = message; | |
28 | + } | |
29 | + | |
30 | + public List<T> getData() { | |
31 | + return data; | |
32 | + } | |
33 | + | |
34 | + public void setData(List<T> data) { | |
35 | + this.data = data; | |
36 | + } | |
37 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/UserAndPermission.java
0 → 100644
... | ... | @@ -0,0 +1,58 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.List; | |
5 | + | |
6 | +public class UserAndPermission implements Serializable { | |
7 | + | |
8 | + private List<String> deviceIds; | |
9 | + | |
10 | + private int userType; | |
11 | + | |
12 | + private String userIds; | |
13 | + | |
14 | + private List<WeekDay> weekDays; | |
15 | + | |
16 | + private String schoolId; | |
17 | + | |
18 | + | |
19 | + public List<String> getDeviceIds() { | |
20 | + return deviceIds; | |
21 | + } | |
22 | + | |
23 | + public void setDeviceIds(List<String> deviceIds) { | |
24 | + this.deviceIds = deviceIds; | |
25 | + } | |
26 | + | |
27 | + public int getUserType() { | |
28 | + return userType; | |
29 | + } | |
30 | + | |
31 | + public void setUserType(int userType) { | |
32 | + this.userType = userType; | |
33 | + } | |
34 | + | |
35 | + public String getUserIds() { | |
36 | + return userIds; | |
37 | + } | |
38 | + | |
39 | + public void setUserIds(String userIds) { | |
40 | + this.userIds = userIds; | |
41 | + } | |
42 | + | |
43 | + public List<WeekDay> getWeekDays() { | |
44 | + return weekDays; | |
45 | + } | |
46 | + | |
47 | + public void setWeekDays(List<WeekDay> weekDays) { | |
48 | + this.weekDays = weekDays; | |
49 | + } | |
50 | + | |
51 | + public String getSchoolId() { | |
52 | + return schoolId; | |
53 | + } | |
54 | + | |
55 | + public void setSchoolId(String schoolId) { | |
56 | + this.schoolId = schoolId; | |
57 | + } | |
58 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/WeekDay.java
1 | 1 | package com.example.dahua.bean; |
2 | 2 | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | + | |
3 | 5 | import java.io.Serializable; |
4 | 6 | import java.util.List; |
5 | 7 | |
6 | 8 | public class WeekDay implements Serializable { |
7 | 9 | |
8 | - private int weekDay; | |
10 | + @ApiModelProperty("用逗号隔开,1:男,2:女") | |
11 | + private String sex; | |
12 | + | |
13 | + @ApiModelProperty("用逗号隔开,0-6表示周日到周六") | |
14 | + private String weekDay; | |
9 | 15 | |
10 | 16 | private List<WeekTime> weekTimes; |
11 | 17 | |
12 | - public int getWeekDay() { | |
18 | + public String getSex() { | |
19 | + return sex; | |
20 | + } | |
21 | + | |
22 | + public void setSex(String sex) { | |
23 | + this.sex = sex; | |
24 | + } | |
25 | + | |
26 | + public String getWeekDay() { | |
13 | 27 | return weekDay; |
14 | 28 | } |
15 | 29 | |
16 | - public void setWeekDay(int weekDay) { | |
30 | + public void setWeekDay(String weekDay) { | |
17 | 31 | this.weekDay = weekDay; |
18 | 32 | } |
19 | 33 | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/WeekTime.java
1 | 1 | package com.example.dahua.bean; |
2 | 2 | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | + | |
3 | 5 | import java.io.Serializable; |
4 | 6 | |
5 | 7 | public class WeekTime implements Serializable { |
6 | 8 | |
9 | + @ApiModelProperty("例: 10:00:00") | |
7 | 10 | private String startTime; |
8 | 11 | |
12 | + @ApiModelProperty("例: 10:00:00") | |
9 | 13 | private String endTime; |
10 | 14 | |
11 | 15 | public String getStartTime() { | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/control/FaceUnifyController.java
0 → 100644
... | ... | @@ -0,0 +1,47 @@ |
1 | +package com.example.dahua.control; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.example.dahua.bean.PermissionBean; | |
5 | +import com.example.dahua.bean.PermissionFaceBean; | |
6 | +import com.example.dahua.bean.ResponseBean; | |
7 | +import com.example.dahua.bean.ResponseBeanList; | |
8 | +import com.example.dahua.service.PermissFaceService; | |
9 | +import io.swagger.annotations.Api; | |
10 | +import io.swagger.annotations.ApiOperation; | |
11 | +import lombok.extern.slf4j.Slf4j; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.web.bind.annotation.*; | |
14 | + | |
15 | +import java.io.UnsupportedEncodingException; | |
16 | + | |
17 | +@Api(tags = "人脸统一处理接口") | |
18 | +@RestController | |
19 | +@RequestMapping(value = "faceUnify/*",produces = "text/plain;charset=UTF-8") | |
20 | +@Slf4j | |
21 | +public class FaceUnifyController { | |
22 | + | |
23 | + @Autowired | |
24 | + PermissFaceService permissFaceService; | |
25 | + | |
26 | + @RequestMapping(value = "sendPermission",method = RequestMethod.POST) | |
27 | + @ApiOperation("添加/编辑/删除权限") | |
28 | + public String sendPermission(@RequestBody PermissionFaceBean permissionFaceBean) throws UnsupportedEncodingException { | |
29 | + return JSON.toJSONString(permissFaceService.addPermissionFace(permissionFaceBean)); | |
30 | + } | |
31 | + | |
32 | + | |
33 | + @RequestMapping(value = "getPermissionDetail",method = RequestMethod.POST) | |
34 | + @ApiOperation("获取权限详情") | |
35 | + @ResponseBody | |
36 | + public String getPermissionDetail(@RequestParam("permissionId")int permissionId) throws UnsupportedEncodingException { | |
37 | + log.error("{}",JSON.toJSONString(permissFaceService.getPermissionDetail(permissionId))); | |
38 | + return JSON.toJSONString(permissFaceService.getPermissionDetail(permissionId)); | |
39 | + } | |
40 | + | |
41 | + @RequestMapping(value = "getPermissions",method = RequestMethod.POST) | |
42 | + @ApiOperation("获取权限列表") | |
43 | + public String getPermissions(@RequestParam("schoolId")int schoolId) throws UnsupportedEncodingException { | |
44 | + return JSON.toJSONString(permissFaceService.getPermissions(schoolId)); | |
45 | + } | |
46 | + | |
47 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java
... | ... | @@ -4,12 +4,14 @@ import com.example.dahua.MyTask; |
4 | 4 | import com.example.dahua.async.SendUserInfoTask; |
5 | 5 | import com.example.dahua.attendance.Attendance; |
6 | 6 | import com.example.dahua.bean.AttendanceBean; |
7 | +import com.example.dahua.bean.PermissionBean; | |
7 | 8 | import com.example.dahua.bean.TeacherBean; |
8 | 9 | import com.example.dahua.bean.UploadImg; |
9 | 10 | import com.example.dahua.dao.UserDao; |
10 | 11 | import com.example.dahua.lib.ToolKits; |
11 | 12 | import com.example.dahua.module.GateModule; |
12 | 13 | import com.example.dahua.service.UserService; |
14 | +import com.example.dahua.utils.HttpUtils; | |
13 | 15 | import com.sun.jna.Memory; |
14 | 16 | import io.swagger.annotations.Api; |
15 | 17 | import io.swagger.annotations.ApiOperation; |
... | ... | @@ -63,6 +65,12 @@ public class FileControl { |
63 | 65 | return "0"; |
64 | 66 | } |
65 | 67 | |
68 | + @RequestMapping(value = "sendPermission", method = RequestMethod.POST) | |
69 | + @ApiOperation(value = "设置权限") | |
70 | + public boolean sendPermission(@RequestBody PermissionBean permissionBean) { | |
71 | + userService.sendPermission(permissionBean); | |
72 | + return true; | |
73 | + } | |
66 | 74 | |
67 | 75 | @RequestMapping(method = RequestMethod.POST, value = "uploadImgToDev") |
68 | 76 | public String uploadImgToDev(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode, | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
... | ... | @@ -4,6 +4,7 @@ import com.example.dahua.MyTask; |
4 | 4 | import com.example.dahua.async.ImageUtils; |
5 | 5 | import com.example.dahua.async.SendUserInfoTask; |
6 | 6 | import com.example.dahua.bean.PermissionBean; |
7 | +import com.example.dahua.bean.UserAndPermission; | |
7 | 8 | import com.example.dahua.lib.CompressPic; |
8 | 9 | import com.example.dahua.service.UserService; |
9 | 10 | import com.example.dahua.utils.*; |
... | ... | @@ -22,6 +23,7 @@ import org.springframework.http.MediaType; |
22 | 23 | import org.springframework.http.ResponseEntity; |
23 | 24 | import org.springframework.util.LinkedMultiValueMap; |
24 | 25 | import org.springframework.util.MultiValueMap; |
26 | +import org.springframework.util.StringUtils; | |
25 | 27 | import org.springframework.web.bind.annotation.*; |
26 | 28 | import org.springframework.web.client.RestTemplate; |
27 | 29 | import org.springframework.web.multipart.MultipartFile; |
... | ... | @@ -60,11 +62,9 @@ public class UserControl { |
60 | 62 | @RequestMapping(value = "sendPermission", method = RequestMethod.POST) |
61 | 63 | @ApiOperation(value = "设置权限") |
62 | 64 | public boolean sendPermission(@RequestBody PermissionBean permissionBean) { |
63 | - userService.sendPermission(permissionBean); | |
64 | - return true; | |
65 | + return HttpUtils.sendPermission(permissionBean); | |
65 | 66 | } |
66 | 67 | |
67 | - | |
68 | 68 | @RequestMapping(value = "imgsSend", method = RequestMethod.GET) |
69 | 69 | @ApiOperation(value = "照片下放") |
70 | 70 | public boolean imgsSend(@RequestParam("schoolId") String schoolId, @RequestParam("type") int type) { | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dao/PermissionFaceDao.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.example.dahua.dao; | |
2 | + | |
3 | +import com.example.dahua.bean.PermissionFaceBean; | |
4 | +import org.apache.ibatis.annotations.Mapper; | |
5 | +import org.apache.ibatis.annotations.Param; | |
6 | +import org.springframework.stereotype.Repository; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +@Repository | |
11 | +public interface PermissionFaceDao { | |
12 | + | |
13 | + | |
14 | + public int addPermissionFace(PermissionFaceBean permissionFaceBean); | |
15 | + | |
16 | + public int updatePermissionFace(PermissionFaceBean permissionFaceBean); | |
17 | + | |
18 | + public int deletePermissionFace(PermissionFaceBean permissionFaceBean); | |
19 | + | |
20 | + public PermissionFaceBean getPerFaceWithId(@Param("id")int id); | |
21 | + | |
22 | + public List<PermissionFaceBean> getPermissFaces(@Param("schoolId") int schoolId); | |
23 | + | |
24 | + public List<PermissionFaceBean> getPermissionDetail(@Param("permissionId") int permissionId); | |
25 | + | |
26 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java
1 | 1 | package com.example.dahua.module; |
2 | 2 | |
3 | 3 | import java.io.UnsupportedEncodingException; |
4 | +import java.util.ArrayList; | |
5 | +import java.util.HashMap; | |
4 | 6 | import java.util.List; |
7 | +import java.util.Map; | |
5 | 8 | |
6 | 9 | import com.example.dahua.bean.PermissionBean; |
7 | 10 | import com.example.dahua.bean.WeekDay; |
... | ... | @@ -189,8 +192,8 @@ public class GateModule { |
189 | 192 | accessCardInfo.sznDoors[0] = 0; |
190 | 193 | accessCardInfo.sznDoors[1] = 1; |
191 | 194 | accessCardInfo.nTimeSectionNum = 2; // 与门数对应 |
192 | - accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 | |
193 | - accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 | |
195 | + accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 | |
196 | + accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 | |
194 | 197 | |
195 | 198 | // 卡状态 |
196 | 199 | accessCardInfo.emStatus = cardStatus; |
... | ... | @@ -254,61 +257,151 @@ public class GateModule { |
254 | 257 | * 门禁刷卡时间段设置 |
255 | 258 | */ |
256 | 259 | public static void setAccessTimeSchedule(LLong lLong, PermissionBean permissionBean) { |
260 | + try { | |
257 | 261 | |
258 | - CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | |
259 | - String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | |
260 | - int nChannel = 120; // 通道号 | |
261 | - | |
262 | + CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | |
263 | + String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | |
264 | + int nChannel = 120; // 通道号 | |
262 | 265 | // msg.stuTimeWeekDay[0].stuTimeSection[0].dwRecordMask |
263 | - String name = "权限模板"; | |
264 | - System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); | |
265 | - | |
266 | - List<WeekDay> weekDays = permissionBean.getWeekDays(); | |
267 | - | |
268 | - for (WeekDay weekDay : | |
269 | - weekDays) { | |
270 | - List<WeekTime> weekTimes = weekDay.getWeekTimes(); | |
271 | - for (int i = 0; i < weekTimes.size(); i++) { | |
272 | - WeekTime weekTime = weekTimes.get(i); | |
273 | - String startTime = weekTime.getStartTime(); | |
274 | - String endTime = weekTime.getEndTime(); | |
275 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginHour = Integer.parseInt(startTime.split(":")[0]); | |
276 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginMin = Integer.parseInt(startTime.split(":")[1]); | |
277 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginSec = 0; | |
278 | - | |
279 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndHour = Integer.parseInt(endTime.split(":")[0]); | |
280 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndMin = Integer.parseInt(endTime.split(":")[1]); | |
281 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndSec = 0; | |
282 | - | |
266 | + String name = "3"; | |
267 | + System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); | |
268 | + msg.bEnable = 1; | |
269 | + | |
270 | + List<WeekDay> weekDays = permissionBean.getWeekDays(); | |
271 | + Map<Integer, List<WeekTime>> map = new HashMap<>(); | |
272 | + | |
273 | + for (WeekDay weekDay : | |
274 | + weekDays) { | |
275 | + //整理时间 | |
276 | + initWeedayAndTimes(weekDay, map); | |
277 | + //设置周计划信息 | |
278 | + for (Map.Entry<Integer, List<WeekTime>> entry : | |
279 | + map.entrySet()) { | |
280 | + | |
281 | + int weekDayIndex = entry.getKey(); | |
282 | + | |
283 | + List<WeekTime> weekTimes = entry.getValue(); | |
284 | + | |
285 | + for (int i = 0; i < weekTimes.size(); i++) { | |
286 | + WeekTime weekTime = weekTimes.get(i); | |
287 | + String startTime = weekTime.getStartTime(); | |
288 | + String endTime = weekTime.getEndTime(); | |
289 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginHour = Integer.parseInt(startTime.split(":")[0]); | |
290 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginMin = Integer.parseInt(startTime.split(":")[1]); | |
291 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginSec = 0; | |
292 | + | |
293 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nEndHour = Integer.parseInt(endTime.split(":")[0]); | |
294 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nEndMin = Integer.parseInt(endTime.split(":")[1]); | |
295 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nEndSec = 0; | |
296 | + } | |
297 | + | |
298 | + } | |
283 | 299 | } |
284 | - } | |
300 | + | |
301 | + | |
302 | + /* for (WeekDay weekDay : | |
303 | + weekDays) { | |
304 | + List<WeekTime> weekTimes = weekDay.getWeekTimes(); | |
305 | + for (int i = 0; i < weekTimes.size(); i++) { | |
306 | + WeekTime weekTime = weekTimes.get(i); | |
307 | + String startTime = weekTime.getStartTime(); | |
308 | + String endTime = weekTime.getEndTime(); | |
309 | + msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginHour = Integer.parseInt(startTime.split(":")[0]); | |
310 | + msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginMin = Integer.parseInt(startTime.split(":")[1]); | |
311 | + msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginSec = 0; | |
312 | + | |
313 | + msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndHour = Integer.parseInt(endTime.split(":")[0]); | |
314 | + msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndMin = Integer.parseInt(endTime.split(":")[1]); | |
315 | + msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndSec = 0; | |
316 | + | |
317 | + } | |
318 | + }*/ | |
285 | 319 | |
286 | 320 | // 获取 |
287 | 321 | // if (ToolKits.GetDevConfig(lLong, nChannel, strCmd, msg)) { |
288 | - System.out.println("Enable:" + msg.bEnable); | |
289 | - try { | |
290 | - System.out.println("自定义名称:" + new String(msg.szName, "UTF-8").trim()); | |
291 | - } catch (UnsupportedEncodingException e) { | |
322 | +// System.out.println("Enable:" + msg.bEnable); | |
323 | +// try { | |
324 | +// System.out.println("自定义名称:" + new String(msg.szName, "UTF-8").trim()); | |
325 | +// } catch (UnsupportedEncodingException e) { | |
326 | +// e.printStackTrace(); | |
327 | +// } | |
328 | +// for (int i = 0; i < 7; i++) { | |
329 | +// for (int j = 0; j < 4; j++) { | |
330 | +// System.out.println("dwRecordMask:" + msg.stuTimeWeekDay[i].stuTimeSection[j].dwRecordMask); | |
331 | +// System.out.println(msg.stuTimeWeekDay[i].stuTimeSection[j].startTime() + "-" + msg.stuTimeWeekDay[i].stuTimeSection[j].endTime() + "\n"); | |
332 | +// } | |
333 | +// } | |
334 | +// msg.write(); | |
335 | + boolean set = ToolKits.SetDevConfig(lLong, nChannel, strCmd, msg); | |
336 | +// msg.read(); | |
337 | + // 设置 | |
338 | + if (set) { | |
339 | + System.out.println("Set AccessTimeSchedule Succeed!"); | |
340 | + } else { | |
341 | + System.err.println("Set AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | |
342 | + } | |
343 | +// } else { | |
344 | +// System.err.println("Get AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | |
345 | +// } | |
346 | + } catch (Exception e) { | |
292 | 347 | e.printStackTrace(); |
293 | 348 | } |
294 | - for (int i = 0; i < 7; i++) { | |
295 | - for (int j = 0; j < 4; j++) { | |
296 | - System.out.println("dwRecordMask:" + msg.stuTimeWeekDay[i].stuTimeSection[j].dwRecordMask); | |
297 | - System.out.println(msg.stuTimeWeekDay[i].stuTimeSection[j].startTime() + "-" + msg.stuTimeWeekDay[i].stuTimeSection[j].endTime() + "\n"); | |
349 | + } | |
350 | + | |
351 | + private static void initWeedayAndTimes(WeekDay weekDay, Map<Integer, List<WeekTime>> map) { | |
352 | + | |
353 | + String weekDayStr = weekDay.getWeekDay(); | |
354 | + String[] weekDays = weekDayStr.split(","); | |
355 | + | |
356 | + List<WeekTime> weekTimes = weekDay.getWeekTimes(); | |
357 | + | |
358 | + for (int i = 0; i < weekDays.length; i++) { | |
359 | + int weekDayIndex = Integer.parseInt(weekDays[i]); | |
360 | + if (map.containsKey(weekDayIndex)) {//周已经有时间段 | |
361 | + List<WeekTime> weekTimeList = map.get(weekDayIndex); | |
362 | + for (WeekTime wee : | |
363 | + weekTimes) { | |
364 | + weekTimeList.add(wee); | |
365 | + } | |
366 | + map.put(weekDayIndex, weekTimeList); | |
367 | + } else { | |
368 | + List<WeekTime> weekTimes1 = new ArrayList<>(); | |
369 | + weekTimes1.addAll(weekTimes); | |
370 | + map.put(weekDayIndex, weekTimes1); | |
298 | 371 | } |
299 | 372 | } |
300 | - msg.write(); | |
301 | - boolean set = ToolKits.SetDevConfig(lLong, nChannel, strCmd, msg); | |
302 | - msg.read(); | |
303 | - // 设置 | |
304 | - if (set) { | |
305 | - System.out.println("Set AccessTimeSchedule Succeed!"); | |
373 | + | |
374 | + } | |
375 | + | |
376 | + public static void getAccessTimeSchedule1(LLong lLong) { | |
377 | + CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | |
378 | + String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | |
379 | + int nChannel = 120; // 通道号 | |
380 | + | |
381 | + // 获取 | |
382 | + if (ToolKits.GetDevConfig(lLong, nChannel, strCmd, msg)) { | |
383 | + System.out.println("Enable:" + msg.bEnable); | |
384 | + try { | |
385 | + System.out.println("自定义名称:" + new String(msg.szName, "utf-8").trim()); | |
386 | + } catch (UnsupportedEncodingException e) { | |
387 | + e.printStackTrace(); | |
388 | + } | |
389 | + for (int i = 0; i < 7; i++) { | |
390 | + for (int j = 0; j < 4; j++) { | |
391 | + System.out.println("dwRecordMask:" + msg.stuTimeWeekDay[i].stuTimeSection[j].dwRecordMask); | |
392 | + System.out.println(msg.stuTimeWeekDay[i].stuTimeSection[j].startTime() + "-" + | |
393 | + msg.stuTimeWeekDay[i].stuTimeSection[j].endTime() + "\n"); | |
394 | + } | |
395 | + } | |
396 | + // 设置 | |
397 | + if (ToolKits.SetDevConfig(lLong, nChannel, strCmd, msg)) { | |
398 | + System.out.println("Set AccessTimeSchedule Succeed!"); | |
399 | + } else { | |
400 | + System.err.println("Set AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | |
401 | + } | |
306 | 402 | } else { |
307 | - System.err.println("Set AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | |
403 | + System.err.println("Get AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | |
308 | 404 | } |
309 | -// } else { | |
310 | -// System.err.println("Get AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | |
311 | -// } | |
312 | 405 | } |
313 | 406 | |
314 | 407 | /** |
... | ... | @@ -450,8 +543,8 @@ public class GateModule { |
450 | 543 | accessCardInfo.sznDoors[0] = 0; |
451 | 544 | accessCardInfo.sznDoors[1] = 1; |
452 | 545 | accessCardInfo.nTimeSectionNum = 2; // 与门数对应 |
453 | - accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 | |
454 | - accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 | |
546 | + accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 | |
547 | + accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 | |
455 | 548 | |
456 | 549 | // 卡状态 |
457 | 550 | accessCardInfo.emStatus = cardStatus; | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/service/AttendanceImp.java
... | ... | @@ -1,70 +0,0 @@ |
1 | -package com.example.dahua.service; | |
2 | - | |
3 | -import com.example.dahua.bean.AttendanceBean; | |
4 | -import org.springframework.beans.factory.annotation.Autowired; | |
5 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
6 | -import org.springframework.jdbc.core.JdbcTemplate; | |
7 | -import org.springframework.stereotype.Service; | |
8 | - | |
9 | -import java.util.List; | |
10 | - | |
11 | -@Service | |
12 | -public class AttendanceImp implements AttendanceService { | |
13 | - | |
14 | - @Autowired | |
15 | - JdbcTemplate jdbcTemplate; | |
16 | - | |
17 | - @Override | |
18 | - public int insert(String clint_id, String clint_type, String ip, String port, String intime, String school_id, String state) { | |
19 | - try { | |
20 | - String selectSql = String.format("select * from SZ_Attendance where clint_id =\'%s\'", clint_id); | |
21 | - List<AttendanceBean> attendanceBeans = jdbcTemplate.query(selectSql, new Object[]{}, new BeanPropertyRowMapper<AttendanceBean>(AttendanceBean.class)); | |
22 | - if (attendanceBeans.size() == 0) {//设备不存在 | |
23 | -// insert SZ_Attendance(clint_id, clint_type, ip, port, intime, school_id, state) | |
24 | -// * values(@clint_id,@clint_type,@ip,@port,GETDATE(),-1,1) | |
25 | - String insertSql = String.format("insert into SZ_Attendance(clint_id, clint_type, ip, port, intime, school_id, state,isConnection) values ('%s','%s','%s','%s','%s','%s','%s','%s')", clint_id, clint_type, ip, port, intime, school_id, state, 1); | |
26 | - return jdbcTemplate.update(insertSql); | |
27 | - } else {//设备 已经存在,更新在线状态 | |
28 | - updateConnectStateWithDevid(1, clint_id); | |
29 | - } | |
30 | - } catch (Exception e) { | |
31 | - e.printStackTrace(); | |
32 | - } | |
33 | - return 0; | |
34 | - } | |
35 | - | |
36 | - /** | |
37 | - * @param isConnection 连接状态 | |
38 | - * @param ip | |
39 | - * @param port | |
40 | - * @return | |
41 | - */ | |
42 | - @Override | |
43 | - public int updateConnectState(int isConnection, String ip, String port) { | |
44 | - | |
45 | - int index = 0; | |
46 | - try { | |
47 | - String updateSql = String.format(" update SZ_Attendance set isConnection = %d where ip = '%s' and port = '%s' ", isConnection, ip, port); | |
48 | - index = jdbcTemplate.update(updateSql); | |
49 | -// System.out.println("updateIndex:"+index+" isConnection:"+isConnection+"updateSql:"+updateSql); | |
50 | - } catch (Exception e) { | |
51 | - e.printStackTrace(); | |
52 | - } | |
53 | - | |
54 | - return index; | |
55 | - } | |
56 | - | |
57 | - @Override | |
58 | - public int updateConnectStateWithDevid(int isConnection, String clint_id) { | |
59 | - int index = 0; | |
60 | - try { | |
61 | - String updateSql = String.format(" update SZ_Attendance set isConnection = %d where clint_id = '%s' ", isConnection, clint_id); | |
62 | - index = jdbcTemplate.update(updateSql); | |
63 | -// System.out.println("updateIndex:"+index+" isConnection:"+isConnection+"updateSql:"+updateSql); | |
64 | - } catch (Exception e) { | |
65 | - e.printStackTrace(); | |
66 | - } | |
67 | - | |
68 | - return index; | |
69 | - } | |
70 | -} |
cloud/dahua/src/main/java/com/example/dahua/service/DeviceServiceImp.java
... | ... | @@ -1,23 +0,0 @@ |
1 | -package com.example.dahua.service; | |
2 | - | |
3 | -import com.example.dahua.MyTask; | |
4 | -import com.example.dahua.module.DeviceControlModule; | |
5 | -import org.springframework.stereotype.Repository; | |
6 | -import org.springframework.stereotype.Service; | |
7 | - | |
8 | -@Repository | |
9 | -@Service | |
10 | -public class DeviceServiceImp implements DeviceService { | |
11 | - | |
12 | - @Override | |
13 | - public boolean restart(String deviceId) { | |
14 | - return DeviceControlModule.reboot(MyTask.lLongMap.get(deviceId)); | |
15 | - } | |
16 | - | |
17 | - @Override | |
18 | - public boolean setDVRIPConfig(String deviceId, String ip, int port) { | |
19 | - | |
20 | - return DeviceControlModule.setDVRIPConfig(deviceId, ip, port); | |
21 | - } | |
22 | - | |
23 | -} |
cloud/dahua/src/main/java/com/example/dahua/service/PermissFaceService.java
0 → 100644
... | ... | @@ -0,0 +1,19 @@ |
1 | +package com.example.dahua.service; | |
2 | + | |
3 | +import com.example.dahua.bean.PermissionFaceBean; | |
4 | +import com.example.dahua.bean.ResponseBean; | |
5 | +import com.example.dahua.bean.ResponseBeanList; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +public interface PermissFaceService { | |
10 | + | |
11 | + | |
12 | + public ResponseBean<PermissionFaceBean> addPermissionFace(PermissionFaceBean permissionFaceBean); | |
13 | + | |
14 | + public ResponseBeanList<PermissionFaceBean> getPermissions(int schoolId); | |
15 | + | |
16 | + public ResponseBeanList<PermissionFaceBean> getPermissionDetail(int permissionId); | |
17 | + | |
18 | + | |
19 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/service/UserServiceImp.java
... | ... | @@ -1,117 +0,0 @@ |
1 | -package com.example.dahua.service; | |
2 | - | |
3 | -import com.example.dahua.MyTask; | |
4 | -import com.example.dahua.async.SendUserInfoTask; | |
5 | -import com.example.dahua.bean.*; | |
6 | -import com.example.dahua.dao.UserDao; | |
7 | -import com.example.dahua.lib.NetSDKLib; | |
8 | -import com.example.dahua.module.GateModule; | |
9 | -import org.apache.commons.lang.StringUtils; | |
10 | -import org.springframework.beans.factory.annotation.Autowired; | |
11 | -import org.springframework.stereotype.Repository; | |
12 | -import org.springframework.stereotype.Service; | |
13 | - | |
14 | -import java.util.List; | |
15 | - | |
16 | -@Repository | |
17 | -@Service | |
18 | -public class UserServiceImp implements UserService { | |
19 | - | |
20 | - @Autowired | |
21 | - UserDao userDao; | |
22 | - | |
23 | - @Autowired | |
24 | - SendUserInfoTask myTask; | |
25 | - | |
26 | - @Override | |
27 | - public List<AttendanceBean> getAttendanceBeans(String schoolId, String clint_type, String devid) { | |
28 | - | |
29 | - if (!StringUtils.isEmpty(devid)) return userDao.getAttendanceBeanWithId(schoolId, clint_type, devid); | |
30 | - | |
31 | - return userDao.getAttendanceBeans(schoolId, clint_type); | |
32 | - } | |
33 | - | |
34 | - @Override | |
35 | - public UserInfoBean getUserInfo(String schoolId, String studentCode) { | |
36 | - return userDao.getUserInfo(schoolId, studentCode); | |
37 | - } | |
38 | - | |
39 | - /** | |
40 | - * 单个用户信息下发 | |
41 | - * | |
42 | - * @param file | |
43 | - * @param schoolId | |
44 | - * @param studentCode | |
45 | - * @param clint_type | |
46 | - * @return | |
47 | - */ | |
48 | - @Override | |
49 | - public boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType, String devid) { | |
50 | - List<AttendanceBean> attendanceBeans = getAttendanceBeans(schoolId, clint_type, devid);//获取学校下的大华设备 | |
51 | - System.out.println("设备数量:" + attendanceBeans.size()); | |
52 | - UserInfoBean userInfoBean = null; | |
53 | - try { | |
54 | - if (userType == 2) { | |
55 | - //根据文件命名来判断学籍号 | |
56 | - String studentCodes = file.split("\\.")[0]; | |
57 | - String[] studentInfo = studentCodes.split("_"); | |
58 | - | |
59 | - if (studentInfo.length > 1) {//附属卡 | |
60 | - | |
61 | - String studentCodeF = studentInfo[0]; | |
62 | - String CardType = studentInfo[1]; | |
63 | - userInfoBean = getUserInfo(schoolId, studentCodeF); | |
64 | - String cardNum = userDao.getCardNum(userInfoBean.getStudent_id(), CardType); | |
65 | - userInfoBean.setStudent_num(cardNum); | |
66 | - | |
67 | - } else { | |
68 | - | |
69 | - userInfoBean = getUserInfo(schoolId, studentCode);//获取用户信息 | |
70 | - | |
71 | - } | |
72 | - } else if (userType == 1) { | |
73 | - TeacherBean teacher = userDao.getTeacher(schoolId, studentCode); | |
74 | - if (null != teacher) { | |
75 | - userInfoBean = new UserInfoBean(); | |
76 | - userInfoBean.setStudent_num(teacher.getTeacher_num()); | |
77 | - userInfoBean.setName(teacher.getName()); | |
78 | - userInfoBean.setUser_id(teacher.getUser_id()); | |
79 | - userInfoBean.setStudentcode(teacher.getNum()); | |
80 | - userInfoBean.setStudent_id(teacher.getTeacher_id()); | |
81 | - } | |
82 | - } | |
83 | - | |
84 | - myTask.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType); | |
85 | - } catch (Exception e) { | |
86 | - e.printStackTrace(); | |
87 | - } | |
88 | - return true; | |
89 | - } | |
90 | - | |
91 | - /** | |
92 | - * 照片下放 | |
93 | - * | |
94 | - * @param schoolId | |
95 | - * @param clint_type | |
96 | - * @param type 0:主卡 1:副卡 | |
97 | - */ | |
98 | - @Override | |
99 | - public void sendUserInfos(String schoolId, String clint_type, int type) { | |
100 | - myTask.doTaskSendUserInfos(schoolId, clint_type, type, -1); | |
101 | - } | |
102 | - | |
103 | - @Override | |
104 | - public boolean sendPermission(PermissionBean permissionBean) { | |
105 | - | |
106 | - List<String> deviceIds = permissionBean.getDeviceIds(); | |
107 | - for (String deviceId : | |
108 | - deviceIds) { | |
109 | - NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(deviceId); | |
110 | - GateModule.setAccessTimeSchedule(loginHandleLong,permissionBean); | |
111 | - } | |
112 | - | |
113 | - | |
114 | - return false; | |
115 | - } | |
116 | - | |
117 | -} |
cloud/dahua/src/main/java/com/example/dahua/service/imp/AttendanceImp.java
0 → 100644
... | ... | @@ -0,0 +1,71 @@ |
1 | +package com.example.dahua.service.imp; | |
2 | + | |
3 | +import com.example.dahua.bean.AttendanceBean; | |
4 | +import com.example.dahua.service.AttendanceService; | |
5 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
7 | +import org.springframework.jdbc.core.JdbcTemplate; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +import java.util.List; | |
11 | + | |
12 | +@Service | |
13 | +public class AttendanceImp implements AttendanceService { | |
14 | + | |
15 | + @Autowired | |
16 | + JdbcTemplate jdbcTemplate; | |
17 | + | |
18 | + @Override | |
19 | + public int insert(String clint_id, String clint_type, String ip, String port, String intime, String school_id, String state) { | |
20 | + try { | |
21 | + String selectSql = String.format("select * from SZ_Attendance where clint_id =\'%s\'", clint_id); | |
22 | + List<AttendanceBean> attendanceBeans = jdbcTemplate.query(selectSql, new Object[]{}, new BeanPropertyRowMapper<AttendanceBean>(AttendanceBean.class)); | |
23 | + if (attendanceBeans.size() == 0) {//设备不存在 | |
24 | +// insert SZ_Attendance(clint_id, clint_type, ip, port, intime, school_id, state) | |
25 | +// * values(@clint_id,@clint_type,@ip,@port,GETDATE(),-1,1) | |
26 | + String insertSql = String.format("insert into SZ_Attendance(clint_id, clint_type, ip, port, intime, school_id, state,isConnection) values ('%s','%s','%s','%s','%s','%s','%s','%s')", clint_id, clint_type, ip, port, intime, school_id, state, 1); | |
27 | + return jdbcTemplate.update(insertSql); | |
28 | + } else {//设备 已经存在,更新在线状态 | |
29 | + updateConnectStateWithDevid(1, clint_id); | |
30 | + } | |
31 | + } catch (Exception e) { | |
32 | + e.printStackTrace(); | |
33 | + } | |
34 | + return 0; | |
35 | + } | |
36 | + | |
37 | + /** | |
38 | + * @param isConnection 连接状态 | |
39 | + * @param ip | |
40 | + * @param port | |
41 | + * @return | |
42 | + */ | |
43 | + @Override | |
44 | + public int updateConnectState(int isConnection, String ip, String port) { | |
45 | + | |
46 | + int index = 0; | |
47 | + try { | |
48 | + String updateSql = String.format(" update SZ_Attendance set isConnection = %d where ip = '%s' and port = '%s' ", isConnection, ip, port); | |
49 | + index = jdbcTemplate.update(updateSql); | |
50 | +// System.out.println("updateIndex:"+index+" isConnection:"+isConnection+"updateSql:"+updateSql); | |
51 | + } catch (Exception e) { | |
52 | + e.printStackTrace(); | |
53 | + } | |
54 | + | |
55 | + return index; | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + public int updateConnectStateWithDevid(int isConnection, String clint_id) { | |
60 | + int index = 0; | |
61 | + try { | |
62 | + String updateSql = String.format(" update SZ_Attendance set isConnection = %d where clint_id = '%s' ", isConnection, clint_id); | |
63 | + index = jdbcTemplate.update(updateSql); | |
64 | +// System.out.println("updateIndex:"+index+" isConnection:"+isConnection+"updateSql:"+updateSql); | |
65 | + } catch (Exception e) { | |
66 | + e.printStackTrace(); | |
67 | + } | |
68 | + | |
69 | + return index; | |
70 | + } | |
71 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/service/imp/DeviceServiceImp.java
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.example.dahua.service.imp; | |
2 | + | |
3 | +import com.example.dahua.MyTask; | |
4 | +import com.example.dahua.module.DeviceControlModule; | |
5 | +import com.example.dahua.service.DeviceService; | |
6 | +import org.springframework.stereotype.Repository; | |
7 | +import org.springframework.stereotype.Service; | |
8 | + | |
9 | +@Repository | |
10 | +@Service | |
11 | +public class DeviceServiceImp implements DeviceService { | |
12 | + | |
13 | + @Override | |
14 | + public boolean restart(String deviceId) { | |
15 | + return DeviceControlModule.reboot(MyTask.lLongMap.get(deviceId)); | |
16 | + } | |
17 | + | |
18 | + @Override | |
19 | + public boolean setDVRIPConfig(String deviceId, String ip, int port) { | |
20 | + | |
21 | + return DeviceControlModule.setDVRIPConfig(deviceId, ip, port); | |
22 | + } | |
23 | + | |
24 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java
0 → 100644
... | ... | @@ -0,0 +1,152 @@ |
1 | +package com.example.dahua.service.imp; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.example.dahua.bean.*; | |
5 | +import com.example.dahua.dao.PermissionFaceDao; | |
6 | +import com.example.dahua.dao.UserDao; | |
7 | +import com.example.dahua.service.PermissFaceService; | |
8 | +import com.example.dahua.utils.HttpUtils; | |
9 | +import lombok.extern.slf4j.Slf4j; | |
10 | +import org.springframework.beans.factory.annotation.Autowired; | |
11 | +import org.springframework.stereotype.Service; | |
12 | +import org.springframework.util.StringUtils; | |
13 | + | |
14 | +import java.util.List; | |
15 | + | |
16 | +@Slf4j | |
17 | +@Service | |
18 | +public class PermissFaceServiceImp implements PermissFaceService { | |
19 | + | |
20 | + @Autowired | |
21 | + PermissionFaceDao permissionFaceDao; | |
22 | + | |
23 | + @Autowired | |
24 | + UserDao userDao; | |
25 | + | |
26 | + @Override | |
27 | + public ResponseBean<PermissionFaceBean> addPermissionFace(PermissionFaceBean permissionFaceBean) { | |
28 | + ResponseBean<PermissionFaceBean> responseBean = new ResponseBean<>(); | |
29 | + try { | |
30 | + int id = permissionFaceBean.getId(); | |
31 | + | |
32 | + String permissName = permissionFaceBean.getPerrmissName(); | |
33 | + | |
34 | + int schoolId = permissionFaceBean.getSchoolId(); | |
35 | + | |
36 | + PermissionBean permissionBean = permissionFaceBean.getPermissionBean(); | |
37 | + | |
38 | + int type = permissionFaceBean.getType(); | |
39 | + if (null != permissionBean) | |
40 | + permissionFaceBean.setPermissionJson(JSON.toJSON(permissionBean).toString()); | |
41 | + | |
42 | + if ((type == 0 || type == 1) && (StringUtils.isEmpty(permissName) || schoolId == 0 || (null != permissionBean && permissionBean.getWeekDays().size() == 0))) { | |
43 | + | |
44 | + responseBean.setStatus(0); | |
45 | + responseBean.setMessage("传入的参数错误"); | |
46 | + responseBean.setData(null); | |
47 | + return responseBean; | |
48 | + } | |
49 | + switch (type) { | |
50 | + case 0://新增 | |
51 | + permissionFaceDao.addPermissionFace(permissionFaceBean); | |
52 | + responseBean.setMessage("添加权限模板成功"); | |
53 | + responseBean.setData(null); | |
54 | + sendPermiss2Dev(permissionFaceBean); | |
55 | + responseBean.setStatus(1); | |
56 | + break; | |
57 | + case 1://编辑 | |
58 | + if (null == permissionFaceDao.getPerFaceWithId(id)) { | |
59 | + responseBean.setMessage("模板不存在"); | |
60 | + } else { | |
61 | + responseBean.setMessage("编辑权限模板成功"); | |
62 | + permissionFaceDao.updatePermissionFace(permissionFaceBean); | |
63 | + } | |
64 | + responseBean.setData(null); | |
65 | + sendPermiss2Dev(permissionFaceBean); | |
66 | + responseBean.setStatus(1); | |
67 | + break; | |
68 | + case 2://删除 | |
69 | + if (null == permissionFaceDao.getPerFaceWithId(id)) { | |
70 | + responseBean.setMessage("模板不存在"); | |
71 | + } else { | |
72 | + permissionFaceDao.deletePermissionFace(permissionFaceBean); | |
73 | + responseBean.setMessage("删除权限模板成功"); | |
74 | + } | |
75 | + responseBean.setData(null); | |
76 | + responseBean.setStatus(1); | |
77 | + break; | |
78 | + } | |
79 | + } catch (Exception e) { | |
80 | + e.printStackTrace(); | |
81 | + responseBean.setStatus(0); | |
82 | + responseBean.setMessage(e.getMessage()); | |
83 | + responseBean.setData(null); | |
84 | + } | |
85 | + return responseBean; | |
86 | + } | |
87 | + | |
88 | + /** | |
89 | + * 下发权限到设备 | |
90 | + * | |
91 | + * @param permissionFaceBean | |
92 | + */ | |
93 | + private void sendPermiss2Dev(PermissionFaceBean permissionFaceBean) { | |
94 | + int schoolId = permissionFaceBean.getSchoolId(); | |
95 | + | |
96 | + PermissionBean permissionBean = permissionFaceBean.getPermissionBean(); | |
97 | + | |
98 | + //查询海康人脸权限一体机 | |
99 | + List<AttendanceBean> attendanceBeanList = userDao.getAttendanceBeans(schoolId + "", "28"); | |
100 | + | |
101 | + //查询大华人脸权限一体机 | |
102 | + List<AttendanceBean> attendanceBeanList1 = userDao.getAttendanceBeans(schoolId + "", "29"); | |
103 | + | |
104 | + if (null != attendanceBeanList && attendanceBeanList.size() > 0) { | |
105 | + if (null != permissionBean) | |
106 | + HttpUtils.sendPermission2HK(permissionFaceBean); | |
107 | + } | |
108 | + | |
109 | + if (null != attendanceBeanList1 && attendanceBeanList1.size() > 0) { | |
110 | + if (null != permissionBean) | |
111 | + HttpUtils.sendPermission(permissionBean); | |
112 | + } | |
113 | + | |
114 | + } | |
115 | + | |
116 | + | |
117 | + | |
118 | + | |
119 | + @Override | |
120 | + public ResponseBeanList<PermissionFaceBean> getPermissions(int schoolId) { | |
121 | + ResponseBeanList responseBeanList = new ResponseBeanList(); | |
122 | + try { | |
123 | + | |
124 | + List<PermissionFaceBean> permissionFaceBeans = permissionFaceDao.getPermissFaces(schoolId); | |
125 | + | |
126 | + responseBeanList.setData(permissionFaceBeans); | |
127 | + | |
128 | + responseBeanList.setMessage(""); | |
129 | + responseBeanList.setStatus(1); | |
130 | + } catch (Exception e) { | |
131 | + e.printStackTrace(); | |
132 | + } | |
133 | + return responseBeanList; | |
134 | + } | |
135 | + | |
136 | + @Override | |
137 | + public ResponseBeanList<PermissionFaceBean> getPermissionDetail(int permissionId) { | |
138 | + ResponseBeanList responseBeanList = new ResponseBeanList(); | |
139 | + try { | |
140 | + | |
141 | + List<PermissionFaceBean> permissionFaceBeans = permissionFaceDao.getPermissionDetail(permissionId); | |
142 | + | |
143 | + responseBeanList.setData(permissionFaceBeans); | |
144 | + | |
145 | + responseBeanList.setMessage(""); | |
146 | + responseBeanList.setStatus(1); | |
147 | + } catch (Exception e) { | |
148 | + e.printStackTrace(); | |
149 | + } | |
150 | + return responseBeanList; | |
151 | + } | |
152 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java
0 → 100644
... | ... | @@ -0,0 +1,120 @@ |
1 | +package com.example.dahua.service.imp; | |
2 | + | |
3 | +import com.example.dahua.MyTask; | |
4 | +import com.example.dahua.async.SendUserInfoTask; | |
5 | +import com.example.dahua.bean.*; | |
6 | +import com.example.dahua.dao.UserDao; | |
7 | +import com.example.dahua.lib.NetSDKLib; | |
8 | +import com.example.dahua.module.GateModule; | |
9 | +import com.example.dahua.service.UserService; | |
10 | +import org.apache.commons.lang.StringUtils; | |
11 | +import org.springframework.beans.factory.annotation.Autowired; | |
12 | +import org.springframework.stereotype.Repository; | |
13 | +import org.springframework.stereotype.Service; | |
14 | + | |
15 | +import java.util.List; | |
16 | + | |
17 | +@Repository | |
18 | +@Service | |
19 | +public class UserServiceImp implements UserService { | |
20 | + | |
21 | + @Autowired | |
22 | + UserDao userDao; | |
23 | + | |
24 | + @Autowired | |
25 | + SendUserInfoTask myTask; | |
26 | + | |
27 | + @Override | |
28 | + public List<AttendanceBean> getAttendanceBeans(String schoolId, String clint_type, String devid) { | |
29 | + | |
30 | + if (!StringUtils.isEmpty(devid)) return userDao.getAttendanceBeanWithId(schoolId, clint_type, devid); | |
31 | + | |
32 | + return userDao.getAttendanceBeans(schoolId, clint_type); | |
33 | + } | |
34 | + | |
35 | + @Override | |
36 | + public UserInfoBean getUserInfo(String schoolId, String studentCode) { | |
37 | + return userDao.getUserInfo(schoolId, studentCode); | |
38 | + } | |
39 | + | |
40 | + /** | |
41 | + * 单个用户信息下发 | |
42 | + * | |
43 | + * @param file | |
44 | + * @param schoolId | |
45 | + * @param studentCode | |
46 | + * @param clint_type | |
47 | + * @return | |
48 | + */ | |
49 | + @Override | |
50 | + public boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType, String devid) { | |
51 | + List<AttendanceBean> attendanceBeans = getAttendanceBeans(schoolId, clint_type, devid);//获取学校下的大华设备 | |
52 | + System.out.println("设备数量:" + attendanceBeans.size()); | |
53 | + UserInfoBean userInfoBean = null; | |
54 | + try { | |
55 | + if (userType == 2) { | |
56 | + //根据文件命名来判断学籍号 | |
57 | + String studentCodes = file.split("\\.")[0]; | |
58 | + String[] studentInfo = studentCodes.split("_"); | |
59 | + | |
60 | + if (studentInfo.length > 1) {//附属卡 | |
61 | + | |
62 | + String studentCodeF = studentInfo[0]; | |
63 | + String CardType = studentInfo[1]; | |
64 | + userInfoBean = getUserInfo(schoolId, studentCodeF); | |
65 | + String cardNum = userDao.getCardNum(userInfoBean.getStudent_id(), CardType); | |
66 | + userInfoBean.setStudent_num(cardNum); | |
67 | + | |
68 | + } else { | |
69 | + | |
70 | + userInfoBean = getUserInfo(schoolId, studentCode);//获取用户信息 | |
71 | + | |
72 | + } | |
73 | + } else if (userType == 1) { | |
74 | + TeacherBean teacher = userDao.getTeacher(schoolId, studentCode); | |
75 | + if (null != teacher) { | |
76 | + userInfoBean = new UserInfoBean(); | |
77 | + userInfoBean.setStudent_num(teacher.getTeacher_num()); | |
78 | + userInfoBean.setName(teacher.getName()); | |
79 | + userInfoBean.setUser_id(teacher.getUser_id()); | |
80 | + userInfoBean.setStudentcode(teacher.getNum()); | |
81 | + userInfoBean.setStudent_id(teacher.getTeacher_id()); | |
82 | + } | |
83 | + } | |
84 | + | |
85 | + myTask.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType); | |
86 | + } catch (Exception e) { | |
87 | + e.printStackTrace(); | |
88 | + } | |
89 | + return true; | |
90 | + } | |
91 | + | |
92 | + /** | |
93 | + * 照片下放 | |
94 | + * | |
95 | + * @param schoolId | |
96 | + * @param clint_type | |
97 | + * @param type 0:主卡 1:副卡 | |
98 | + */ | |
99 | + @Override | |
100 | + public void sendUserInfos(String schoolId, String clint_type, int type) { | |
101 | + myTask.doTaskSendUserInfos(schoolId, clint_type, type, -1); | |
102 | + } | |
103 | + | |
104 | + @Override | |
105 | + public boolean sendPermission(PermissionBean permissionBean) { | |
106 | + | |
107 | + List<String> deviceIds = permissionBean.getDeviceIds(); | |
108 | + if (null != deviceIds) | |
109 | + for (String deviceId : | |
110 | + deviceIds) { | |
111 | + NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(deviceId); | |
112 | + GateModule.setAccessTimeSchedule(loginHandleLong, permissionBean); | |
113 | + GateModule.getAccessTimeSchedule1(loginHandleLong); | |
114 | + } | |
115 | + | |
116 | + | |
117 | + return false; | |
118 | + } | |
119 | + | |
120 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java
1 | 1 | package com.example.dahua.utils; |
2 | 2 | |
3 | +import com.example.dahua.bean.PermissionBean; | |
4 | +import com.example.dahua.bean.PermissionFaceBean; | |
5 | +import com.example.dahua.bean.PermissionHKBean; | |
3 | 6 | import com.example.dahua.lib.CompressPic; |
4 | 7 | import com.example.dahua.lib.FilePath; |
5 | 8 | import org.springframework.core.io.FileSystemResource; |
... | ... | @@ -69,4 +72,52 @@ public class HttpUtils { |
69 | 72 | } |
70 | 73 | |
71 | 74 | |
75 | + public static boolean sendPermission(PermissionBean permissionBean) { | |
76 | + String url = "http://121.40.109.21:8991/file/sendPermission"; | |
77 | + RestTemplate restTemplate = new RestTemplate(); | |
78 | + | |
79 | + HttpHeaders headers = new HttpHeaders(); | |
80 | + | |
81 | + MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE); | |
82 | + | |
83 | + headers.setContentType(mediaType); | |
84 | + | |
85 | + HttpEntity<PermissionBean> httpEntity = new HttpEntity<>(permissionBean, headers); | |
86 | + | |
87 | + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | |
88 | + | |
89 | + System.out.println("大华设备下发权限:" + responseEntity.getBody()); | |
90 | + return responseEntity.getBody().equals("1"); | |
91 | + } | |
92 | + | |
93 | + public static void sendPermission2HK(PermissionFaceBean permissionFaceBean) { | |
94 | + String url = "http://114.55.30.100:8089/facereco/sendPermiss"; | |
95 | + PermissionBean permissionBean = permissionFaceBean.getPermissionBean(); | |
96 | + | |
97 | + if (null!=permissionBean){ | |
98 | + | |
99 | + PermissionHKBean permissionHKBean = new PermissionHKBean(); | |
100 | + | |
101 | + permissionHKBean.setDeviceIds(permissionBean.getDeviceIds()); | |
102 | + permissionHKBean.setSchoolId(permissionFaceBean.getSchoolId()+""); | |
103 | + permissionHKBean.setUserType("2"); | |
104 | + permissionHKBean.setWeekDays(permissionBean.getWeekDays()); | |
105 | + | |
106 | + RestTemplate restTemplate = new RestTemplate(); | |
107 | + | |
108 | + HttpHeaders headers = new HttpHeaders(); | |
109 | + | |
110 | + MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE); | |
111 | + | |
112 | + headers.setContentType(mediaType); | |
113 | + | |
114 | + HttpEntity<PermissionHKBean> httpEntity = new HttpEntity<>(permissionHKBean, headers); | |
115 | + | |
116 | + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | |
117 | + | |
118 | + System.out.println("海康设备下发权限:" + responseEntity.getBody()); | |
119 | + | |
120 | + } | |
121 | + | |
122 | + } | |
72 | 123 | } | ... | ... |
cloud/dahua/src/main/resources/application.yml
... | ... | @@ -14,10 +14,10 @@ spring: |
14 | 14 | password: RQminVCJota3H1u8bBYH |
15 | 15 | jdbc-url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus |
16 | 16 | driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
17 | - # username: SZJXTUSER | |
18 | - # password: xst200919 | |
19 | - # jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=SmartCampusSZ | |
20 | - # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
17 | +# username: SZJXTUSER | |
18 | +# password: xst200919 | |
19 | +# jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=SmartCampusSZ | |
20 | +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
21 | 21 | xiaoan: |
22 | 22 | jdbc-url: jdbc:sqlserver://116.62.241.27:33419;database=xiaoanhxy |
23 | 23 | username: szjxtuser | ... | ... |
cloud/dahua/src/main/resources/mapper/PermissionFaceMapper.xml
0 → 100644
... | ... | @@ -0,0 +1,55 @@ |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | |
3 | +<mapper namespace="com.example.dahua.dao.PermissionFaceDao"> | |
4 | + | |
5 | +<!-- create table PermissionFace (--> | |
6 | +<!-- id int not null PRIMARY KEY ,--> | |
7 | +<!-- permissionJSON varchar(max) not null ,--> | |
8 | +<!-- schoolId int not null ,--> | |
9 | +<!-- perrmissName varchar(50) not null ,--> | |
10 | +<!-- createTime varchar(50) not null ,--> | |
11 | +<!-- updateTime varchar(50) not null ,--> | |
12 | +<!-- )--> | |
13 | + <resultMap id="permissFaceBase" type="com.example.dahua.bean.PermissionFaceBean"> | |
14 | + | |
15 | + <result column="id" property="id"/> | |
16 | + <result column="permissionJSON" property="permissionJson"/> | |
17 | + <result column="schoolId" property="schoolId"/> | |
18 | + <result column="perrmissName" property="perrmissName"/> | |
19 | + <result column="createTime" property="createTime"/> | |
20 | + <result column="updateTime" property="updateTime"/> | |
21 | + | |
22 | + </resultMap> | |
23 | + | |
24 | + <insert id="addPermissionFace" parameterType="com.example.dahua.bean.PermissionFaceBean"> | |
25 | + | |
26 | + insert into PermissionFace values (#{permissionJson},#{schoolId},#{perrmissName},#{createTime},#{updateTime}) | |
27 | + | |
28 | + </insert> | |
29 | + | |
30 | + | |
31 | + <select id="getPermissFaces" parameterType="java.lang.Integer" resultMap="permissFaceBase"> | |
32 | + | |
33 | + select * from PermissionFace where schoolId = #{schoolId}; | |
34 | + | |
35 | + </select> | |
36 | + <select id="getPermissionDetail" parameterType="java.lang.Integer" resultMap="permissFaceBase"> | |
37 | + | |
38 | + select * from PermissionFace where id = #{permissionId}; | |
39 | + | |
40 | + </select> | |
41 | + <update id="updatePermissionFace" parameterType="com.example.dahua.bean.PermissionFaceBean"> | |
42 | + | |
43 | + update PermissionFace set permissionJson = #{permissionJson},updateTime=#{updateTime},perrmissName=#{perrmissName} where id = #{id} | |
44 | + | |
45 | + </update> | |
46 | + | |
47 | + <delete id="deletePermissionFace" parameterType="java.lang.Integer"> | |
48 | + delete from PermissionFace where id = #{id} | |
49 | + </delete> | |
50 | + | |
51 | + <select id="getPerFaceWithId" parameterType="java.lang.Integer" resultType="com.example.dahua.bean.PermissionFaceBean"> | |
52 | + select * from PermissionFace where id =#{id}; | |
53 | + </select> | |
54 | + | |
55 | +</mapper> | |
0 | 56 | \ No newline at end of file | ... | ... |
cloud/dahua/src/main/resources/mapper/usermapper.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
3 | -<mapper namespace="com.example.dahua.dao"> | |
3 | +<mapper namespace="com.example.dahua.dao.UserDao"> | |
4 | 4 | |
5 | 5 | <!--<select id="getStudentNum" resultType="String" parameterType="String">--> |
6 | 6 | <!--select student_num--> |
... | ... | @@ -9,4 +9,14 @@ |
9 | 9 | <!--and studentcode = #{studentcode}--> |
10 | 10 | <!--</select>--> |
11 | 11 | |
12 | + <select id="getStudentWiSidAndSex" resultType="java.lang.String"> | |
13 | + | |
14 | + select student_num from SZ_V_School_Student where school_id = #{schoolId} and sex in | |
15 | + <foreach collection="sexs" item="sex" index="index" open="(" separator="," close=")"> | |
16 | + #{sex} | |
17 | + </foreach> | |
18 | + | |
19 | + </select> | |
20 | + | |
21 | + | |
12 | 22 | </mapper> |
13 | 23 | \ No newline at end of file | ... | ... |
cloud/fIle-center/src/main/java/com/sincere/file/config/AllowOriginFilter.java
0 → 100644
... | ... | @@ -0,0 +1,37 @@ |
1 | +package com.sincere.file.config; | |
2 | + | |
3 | +import org.springframework.stereotype.Component; | |
4 | + | |
5 | +import javax.servlet.*; | |
6 | +import javax.servlet.annotation.WebFilter; | |
7 | +import javax.servlet.http.HttpServletResponse; | |
8 | +import java.io.IOException; | |
9 | + | |
10 | +/** | |
11 | + * 用于解决跨域问题 | |
12 | + * | |
13 | + * @author chen | |
14 | + * @version 1.0 | |
15 | + * @date 2019/10/11 0011 10:17 | |
16 | + */ | |
17 | +@Component | |
18 | +@WebFilter(urlPatterns = "/*", filterName = "authFilter") | |
19 | +public class AllowOriginFilter implements Filter { | |
20 | + | |
21 | + @Override | |
22 | + public void init(FilterConfig filterConfig) throws ServletException { | |
23 | + } | |
24 | + | |
25 | + public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { | |
26 | + HttpServletResponse response = (HttpServletResponse) res; | |
27 | + response.setHeader("Access-Control-Allow-Origin", "*"); | |
28 | + response.setHeader("Access-Control-Allow-Methods", "*"); | |
29 | + response.setHeader("Access-Control-Allow-Credentials", "true"); | |
30 | + response.setHeader("Access-Control-Allow-Headers", "*"); | |
31 | + chain.doFilter(req, res); | |
32 | + } | |
33 | + | |
34 | + @Override | |
35 | + public void destroy() { | |
36 | + } | |
37 | +} | ... | ... |
cloud/getaway/src/main/resources/application.yml
... | ... | @@ -69,6 +69,12 @@ spring: |
69 | 69 | - Path=/haikang/** |
70 | 70 | filters: |
71 | 71 | - StripPrefix=1 |
72 | + - id: haikangface | |
73 | + uri: http://120.26.116.253:8089 | |
74 | + predicates: | |
75 | + - Path=/haikangface/** | |
76 | + filters: | |
77 | + - StripPrefix=1 | |
72 | 78 | # default-filters: |
73 | 79 | # - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE |
74 | 80 | # discovery: |
... | ... | @@ -92,4 +98,4 @@ ribbon: |
92 | 98 | |
93 | 99 | |
94 | 100 | url: |
95 | - ignored: /SmartCampusWebApi/**,/authserver/**,/NewSmartCampus/**,/file-center/**,/dahua/**,/haikang/** | |
96 | 101 | \ No newline at end of file |
102 | + ignored: /SmartCampusWebApi/**,/authserver/**,/NewSmartCampus/**,/file-center/**,/dahua/**,/haikang/**,/haikangface/** | |
97 | 103 | \ No newline at end of file | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
... | ... | @@ -19,8 +19,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
19 | 19 | import org.springframework.beans.factory.annotation.Value; |
20 | 20 | import org.springframework.boot.ApplicationArguments; |
21 | 21 | import org.springframework.boot.ApplicationRunner; |
22 | +import org.springframework.http.ResponseEntity; | |
22 | 23 | import org.springframework.stereotype.Component; |
23 | 24 | import org.springframework.util.StringUtils; |
25 | +import org.springframework.web.client.RestTemplate; | |
24 | 26 | |
25 | 27 | import java.io.*; |
26 | 28 | import java.net.InetAddress; |
... | ... | @@ -29,6 +31,7 @@ import java.nio.ByteBuffer; |
29 | 31 | import java.text.SimpleDateFormat; |
30 | 32 | import java.util.Date; |
31 | 33 | import java.util.HashMap; |
34 | +import java.util.List; | |
32 | 35 | import java.util.Map; |
33 | 36 | import java.util.regex.Pattern; |
34 | 37 | |
... | ... | @@ -48,7 +51,8 @@ public class CMSServer implements ApplicationRunner { |
48 | 51 | //114.55.30.100 |
49 | 52 | //120.26.116.253 |
50 | 53 | private String ip_cloud = "120.26.116.253"; |
51 | - // private String ip_cloud = "114.55.30.100"; | |
54 | + // private String ip_cloud = "172.16.2.56"; | |
55 | +// private String ip_cloud = "114.55.30.100"; | |
52 | 56 | private String ip; |
53 | 57 | |
54 | 58 | { |
... | ... | @@ -122,7 +126,7 @@ public class CMSServer implements ApplicationRunner { |
122 | 126 | public class FRegisterCallBack implements HCEHomeCMS.DEVICE_REGISTER_CB { |
123 | 127 | public boolean invoke(NativeLong lUserID, int dwDataType, Pointer pOutBuffer, int dwOutLen, HCEHomeCMS.NET_EHOME_SERVER_INFO pInBuffer, int dwInLen, Pointer pUser) { |
124 | 128 | String deviceId = ""; |
125 | - System.out.println("dwDataType:" + dwDataType); | |
129 | +// System.out.println("dwDataType:" + dwDataType); | |
126 | 130 | if (dwDataType == 0) { |
127 | 131 | HCEHomeCMS.NET_EHOME_DEV_REG_INFO strDevRegInfo = new HCEHomeCMS.NET_EHOME_DEV_REG_INFO(); |
128 | 132 | strDevRegInfo.write(); |
... | ... | @@ -137,7 +141,10 @@ public class CMSServer implements ApplicationRunner { |
137 | 141 | pInBuffer.dwSize = pInBuffer.size(); |
138 | 142 | AttendanceBean attendanceBean = new AttendanceBean(); |
139 | 143 | attendanceBean.setClint_id(deviceId); |
140 | - attendanceBean.setClint_type("18"); | |
144 | + if (deviceId.startsWith("ytj")) | |
145 | + attendanceBean.setClint_type("28"); | |
146 | + else | |
147 | + attendanceBean.setClint_type("18"); | |
141 | 148 | attendanceBean.setIntime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
142 | 149 | attendanceBean.setIsConnection(1); |
143 | 150 | attendanceBean.setSchool_id("-1"); |
... | ... | @@ -280,7 +287,7 @@ public class CMSServer implements ApplicationRunner { |
280 | 287 | |
281 | 288 | public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { |
282 | 289 | String strPath = "C://EhomePicServer/"; |
283 | - System.out.println("pFileName:" + pFileName); | |
290 | +// System.out.println("pFileName:" + pFileName); | |
284 | 291 | pFileName = pFileName.replace("_", ""); |
285 | 292 | boolean isZhuaPai = false; |
286 | 293 | if (pFileName.contains("-")) {//人脸抓拍机抓拍到的图片 |
... | ... | @@ -405,7 +412,7 @@ public class CMSServer implements ApplicationRunner { |
405 | 412 | strXMLData.read(); |
406 | 413 | |
407 | 414 | String strXML = new String(strXMLData.byValue); |
408 | - System.out.println(strXML); | |
415 | +// System.out.println(strXML); | |
409 | 416 | |
410 | 417 | if (null == alarmUtils) { |
411 | 418 | alarmUtils = new AlarmUtils(deviceDao); |
... | ... | @@ -439,7 +446,7 @@ public class CMSServer implements ApplicationRunner { |
439 | 446 | } |
440 | 447 | |
441 | 448 | } |
442 | - System.out.println("监听回调"); | |
449 | +// System.out.println("监听回调"); | |
443 | 450 | return true; |
444 | 451 | } |
445 | 452 | } |
... | ... | @@ -484,8 +491,11 @@ public class CMSServer implements ApplicationRunner { |
484 | 491 | face_recoder.getImgurl(), face_recoder.getInOrOut(), face_recoder.getTime(), face_recoder.getCardNum(), currTemperature); |
485 | 492 | } |
486 | 493 | } else { |
494 | + //教师点名 | |
495 | + isTeacher(cardNo, deviceID); | |
487 | 496 | FileUtils.getInstance().writeLogs("card:" + card, FileUtils.faceSuccess); |
488 | 497 | } |
498 | + | |
489 | 499 | } |
490 | 500 | |
491 | 501 | } catch (Exception e) { |
... | ... | @@ -493,6 +503,29 @@ public class CMSServer implements ApplicationRunner { |
493 | 503 | } |
494 | 504 | } |
495 | 505 | |
506 | + public void isTeacher(String cardNo, String deviceID) { | |
507 | + | |
508 | + | |
509 | + List<String> devLists = userDao.getDeviceRoomRelation(deviceID); | |
510 | + | |
511 | + if (null != devLists && devLists.size() > 0) { | |
512 | + | |
513 | + StudentBean teacher = userDao.getTeacherWithCard(cardNo); | |
514 | + if (null != teacher) { | |
515 | + String url = String.format("http://60.190.202.57:1000/api/RollCall/AddRollCallPersonnelRecord?userId=%s&deviceId=%s", teacher.getUser_id(), deviceID); | |
516 | + | |
517 | + RestTemplate restTemplate = new RestTemplate(); | |
518 | + | |
519 | + | |
520 | + String res = restTemplate.getForObject(url, String.class); | |
521 | + | |
522 | + System.out.println("result:" + res + "------url:" + url); | |
523 | + | |
524 | + } | |
525 | + } | |
526 | + | |
527 | + } | |
528 | + | |
496 | 529 | /** |
497 | 530 | * 生成图片服务路径 |
498 | 531 | * |
... | ... | @@ -602,17 +635,17 @@ public class CMSServer implements ApplicationRunner { |
602 | 635 | "<password>MTIzNDU2</password>\r\n" + |
603 | 636 | "<maxSwipeTime></maxSwipeTime>\r\n" + |
604 | 637 | "<swipeTime></swipeTime>\r\n" + |
605 | - "<groupNo></groupNo>\r\n" + | |
606 | - "<employeeNo>" + employeeNo + "</employeeNo>\r\n" + | |
638 | + "<groupNo>5</groupNo>\r\n" + | |
607 | 639 | "<name>"; |
608 | 640 | String nameAfter = "</name>\r\n" + |
609 | - "<departmentNo></departmentNo>\r\n" + | |
641 | + "<employeeNo>" + employeeNo + "</employeeNo>\r\n" + | |
642 | + "<departmentNo>3</departmentNo>\r\n" + | |
610 | 643 | "<schedulePlanNo></schedulePlanNo>\r\n" + |
611 | 644 | "<schedulePlanType></schedulePlanType>\r\n" + |
612 | 645 | "</CardCfg>\r\n" + |
613 | 646 | "</ConfigXML>\r\n" + |
614 | 647 | "</Params>"; |
615 | -// System.out.println("strConfigXMLCard:" + strConfigXMLCard + name + nameAfter); | |
648 | + System.out.println("strConfigXMLCard:" + strConfigXMLCard + name + nameAfter); | |
616 | 649 | byte[] nameBeforBy = null; |
617 | 650 | byte[] resultBy = null; |
618 | 651 | try { |
... | ... | @@ -676,50 +709,50 @@ public class CMSServer implements ApplicationRunner { |
676 | 709 | public void SetCardWeekPlan(String clint_id, String card, String userType, String strConfigXMLCard, String content) { |
677 | 710 | try { |
678 | 711 | |
679 | - HCEHomeCMS.NET_EHOME_XML_CFG struXMLCard = new HCEHomeCMS.NET_EHOME_XML_CFG(); | |
680 | - | |
681 | - HCEHomeCMS.NET_DVR_STRING_POINTER stringRequestCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
682 | - stringRequestCard.read(); | |
683 | - String strRequestCard = "SETDEVICECONFIG"; | |
684 | - stringRequestCard.byString = strRequestCard.getBytes(); | |
685 | - stringRequestCard.write(); | |
686 | - | |
687 | - struXMLCard.pCmdBuf = stringRequestCard.getPointer(); | |
688 | - struXMLCard.dwCmdLen = stringRequestCard.byString.length; | |
689 | - struXMLCard.write(); | |
690 | - | |
691 | - HCEHomeCMS.NET_DVR_STRING_POINTER struConfigXMLCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
692 | - struConfigXMLCard.read(); | |
693 | - struConfigXMLCard.byString = strConfigXMLCard.getBytes(); | |
694 | - struConfigXMLCard.write(); | |
695 | - | |
696 | - struXMLCard.pInBuf = struConfigXMLCard.getPointer(); | |
697 | - struXMLCard.dwInSize = struConfigXMLCard.byString.length; | |
698 | - struXMLCard.dwRecvTimeOut = 5000; | |
699 | - struXMLCard.dwSendTimeOut = 5000; | |
700 | - struXMLCard.write(); | |
701 | - | |
702 | - HCEHomeCMS.NET_DVR_STRING_POINTER stringOutCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
703 | - stringOutCard.write(); | |
704 | - struXMLCard.pOutBuf = stringOutCard.getPointer(); | |
705 | - struXMLCard.dwOutSize = stringOutCard.size(); | |
706 | - struXMLCard.write(); | |
707 | - | |
708 | - HCEHomeCMS.NET_DVR_STRING_POINTER stringStatusCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
709 | - stringStatusCard.write(); | |
710 | - struXMLCard.pStatusBuf = stringStatusCard.getPointer(); | |
711 | - struXMLCard.dwStatusSize = stringStatusCard.size(); | |
712 | - struXMLCard.write(); | |
713 | - | |
714 | - int i = struXMLCard.size(); | |
715 | - if (!hCEhomeCMS.NET_ECMS_XMLConfig(map.get(clint_id), struXMLCard, struXMLCard.size())) { | |
716 | - int iErr = hCEhomeCMS.NET_ECMS_GetLastError(); | |
717 | - System.err.println(content + "失败:" + iErr); | |
718 | - sendRecoderUtils.sendFail(sendRecordDao, card, "", clint_id, userDao, content + "失败:" + iErr, userType); | |
719 | - } else { | |
720 | - System.out.println(content + "成功"); | |
721 | - } | |
722 | - }catch (Exception e){ | |
712 | + HCEHomeCMS.NET_EHOME_XML_CFG struXMLCard = new HCEHomeCMS.NET_EHOME_XML_CFG(); | |
713 | + | |
714 | + HCEHomeCMS.NET_DVR_STRING_POINTER stringRequestCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
715 | + stringRequestCard.read(); | |
716 | + String strRequestCard = "SETDEVICECONFIG"; | |
717 | + stringRequestCard.byString = strRequestCard.getBytes(); | |
718 | + stringRequestCard.write(); | |
719 | + | |
720 | + struXMLCard.pCmdBuf = stringRequestCard.getPointer(); | |
721 | + struXMLCard.dwCmdLen = stringRequestCard.byString.length; | |
722 | + struXMLCard.write(); | |
723 | + | |
724 | + HCEHomeCMS.NET_DVR_STRING_POINTER struConfigXMLCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
725 | + struConfigXMLCard.read(); | |
726 | + struConfigXMLCard.byString = strConfigXMLCard.getBytes(); | |
727 | + struConfigXMLCard.write(); | |
728 | + | |
729 | + struXMLCard.pInBuf = struConfigXMLCard.getPointer(); | |
730 | + struXMLCard.dwInSize = struConfigXMLCard.byString.length; | |
731 | + struXMLCard.dwRecvTimeOut = 5000; | |
732 | + struXMLCard.dwSendTimeOut = 5000; | |
733 | + struXMLCard.write(); | |
734 | + | |
735 | + HCEHomeCMS.NET_DVR_STRING_POINTER stringOutCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
736 | + stringOutCard.write(); | |
737 | + struXMLCard.pOutBuf = stringOutCard.getPointer(); | |
738 | + struXMLCard.dwOutSize = stringOutCard.size(); | |
739 | + struXMLCard.write(); | |
740 | + | |
741 | + HCEHomeCMS.NET_DVR_STRING_POINTER stringStatusCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); | |
742 | + stringStatusCard.write(); | |
743 | + struXMLCard.pStatusBuf = stringStatusCard.getPointer(); | |
744 | + struXMLCard.dwStatusSize = stringStatusCard.size(); | |
745 | + struXMLCard.write(); | |
746 | + | |
747 | + int i = struXMLCard.size(); | |
748 | + if (!hCEhomeCMS.NET_ECMS_XMLConfig(map.get(clint_id), struXMLCard, struXMLCard.size())) { | |
749 | + int iErr = hCEhomeCMS.NET_ECMS_GetLastError(); | |
750 | + System.err.println(content + "失败:" + iErr); | |
751 | + sendRecoderUtils.sendFail(sendRecordDao, card, "", clint_id, userDao, content + "失败:" + iErr, userType); | |
752 | + } else { | |
753 | + System.out.println(content + "成功"); | |
754 | + } | |
755 | + } catch (Exception e) { | |
723 | 756 | e.printStackTrace(); |
724 | 757 | } |
725 | 758 | } | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
1 | 1 | package com.sincere.haikangface.async; |
2 | 2 | |
3 | 3 | |
4 | +import com.alibaba.fastjson.JSON; | |
4 | 5 | import com.sincere.haikangface.CMSServer; |
6 | +import com.sincere.haikangface.bean.StudentBean; | |
7 | +import com.sincere.haikangface.bean.TeacherBean; | |
5 | 8 | import com.sincere.haikangface.bean.face.PermissionBean; |
6 | 9 | import com.sincere.haikangface.bean.face.WeekDay; |
7 | 10 | import com.sincere.haikangface.bean.face.WeekTime; |
... | ... | @@ -10,18 +13,11 @@ import com.sincere.haikangface.dao.UserDao; |
10 | 13 | import com.sincere.haikangface.utils.*; |
11 | 14 | import com.sincere.haikangface.xiananDao.SendRecordDao; |
12 | 15 | import lombok.extern.slf4j.Slf4j; |
13 | -import org.apache.poi.ss.formula.functions.WeekdayFunc; | |
14 | -import org.json.JSONArray; | |
15 | -import org.json.JSONObject; | |
16 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
17 | 17 | import org.springframework.scheduling.annotation.Async; |
18 | 18 | import org.springframework.stereotype.Component; |
19 | -import org.springframework.web.bind.annotation.RequestParam; | |
19 | +import org.springframework.util.StringUtils; | |
20 | 20 | |
21 | -import javax.imageio.stream.FileImageInputStream; | |
22 | -import java.io.*; | |
23 | -import java.net.HttpURLConnection; | |
24 | -import java.net.URL; | |
25 | 21 | import java.util.*; |
26 | 22 | |
27 | 23 | @Component |
... | ... | @@ -53,13 +49,30 @@ public class SendUserAsync { |
53 | 49 | //根据设备是5603 还是新设备 |
54 | 50 | String employeeNo = ""; |
55 | 51 | if (deviceId.contains("ymzx") || deviceId.contains("5607") || deviceId.contains("5671") || deviceId.contains("5604")) { |
56 | - employeeNo = System.currentTimeMillis() + ""; | |
57 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板"); | |
58 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划"); | |
59 | - for (int i = 0; i < 7; i++) { | |
60 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlanTime(HKXmlUtils.getInstance().SetCardWeekPlanTimes("00:00:00", "23:00:00"), "" + i), "设置卡权限周计划时间"); | |
52 | + long lon = Long.parseLong(card); | |
53 | + //十六进制卡号 | |
54 | + String resultCard = getCard(String.format("%08x", lon)).toUpperCase(); | |
55 | + String time = System.currentTimeMillis() + ""; | |
56 | + if (userType.equals("1")) { | |
57 | + StudentBean studentBean = userDao.getTeacherWithCard(resultCard); | |
58 | + log.error("studentBean:{}", studentBean == null ? "-------" : studentBean.toString()); | |
59 | + if (null == studentBean) { | |
60 | + employeeNo = time.substring(time.length() - 6, time.length()); | |
61 | + } else | |
62 | + employeeNo = studentBean.getTeacher_id(); | |
63 | + } else if (userType.equals("2")) { | |
64 | + StudentBean studentBean = userDao.getStudentWithCard(resultCard); | |
65 | + if (null == studentBean) { | |
66 | + employeeNo = time.substring(time.length() - 6, time.length()); | |
67 | + } else | |
68 | + employeeNo = studentBean.getStudent_id(); | |
61 | 69 | } |
62 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限"); | |
70 | +// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板"); | |
71 | +// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划"); | |
72 | +// for (int i = 0; i < 7; i++) { | |
73 | +// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlanTime(HKXmlUtils.getInstance().SetCardWeekPlanTimes("00:00:00", "23:00:00"), "" + i), "设置卡权限周计划时间"); | |
74 | +// } | |
75 | +// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限"); | |
63 | 76 | } |
64 | 77 | |
65 | 78 | boolean result = cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo); |
... | ... | @@ -72,52 +85,202 @@ public class SendUserAsync { |
72 | 85 | |
73 | 86 | /** |
74 | 87 | * 下发权限 |
88 | + * | |
75 | 89 | * @param permissionBean |
90 | + * @param i 1:不需要重新下发,0需要重新下发 | |
76 | 91 | */ |
77 | - public boolean sendPermiss(PermissionBean permissionBean) { | |
92 | + @Async("taskExecutor") | |
93 | + public boolean sendPermiss(PermissionBean permissionBean, int i) { | |
94 | + | |
95 | + String userType = permissionBean.getUserType(); | |
96 | + | |
97 | + List<WeekDay> weekDays = permissionBean.getWeekDays(); | |
98 | + | |
99 | + Map<Integer, List<WeekTime>> map = new HashMap<>(); | |
100 | + | |
101 | + String schoolId = permissionBean.getSchoolId(); | |
102 | + | |
103 | + for (WeekDay weekDay : | |
104 | + weekDays) { | |
105 | + if (weekDay.getDeviceIds() != null && weekDay.getDeviceIds().size() > 0) { | |
106 | + permissionBean.setDeviceIds(weekDay.getDeviceIds()); | |
107 | + } | |
108 | + List<String> deviceIds = permissionBean.getDeviceIds(); | |
109 | + List<String> cardNumList = new ArrayList<>(); | |
110 | + String sex = weekDay.getSex(); | |
111 | + if (userType.equals("1")) { | |
112 | + List<String> cardList = getUserCard(weekDay.getUserIds(), 1); | |
113 | + cardNumList.addAll(cardList); | |
114 | + } else if (userType.equals("2")) { | |
115 | + cardNumList = getCards(sex, userType, schoolId); | |
116 | + } | |
117 | + //整理周和时间段 | |
118 | + initWeedayAndTimes(weekDay, map); | |
119 | + senPsermiss(permissionBean, map, deviceIds, cardNumList, i); | |
120 | + } | |
121 | + log.error("map{}", JSON.toJSONString(map)); | |
122 | + return true; | |
123 | + } | |
124 | + | |
125 | + private List<String> getUserCard(String userIds, int userType) { | |
126 | + List<String> cards = new ArrayList<>(); | |
127 | + try { | |
128 | + | |
129 | + String[] userIdsStr = userIds.split(","); | |
130 | + | |
131 | + for (String userId : | |
132 | + userIdsStr) { | |
133 | + TeacherBean teacherBean = null; | |
134 | + if (userType == 1) {//教师 | |
135 | + teacherBean = userDao.getTeacherWithUserId(userId); | |
136 | + if (null != teacherBean) { | |
137 | + String card = teacherBean.getTeacer_num(); | |
138 | + if (!StringUtils.isEmpty(card)) { | |
139 | + cards.add(card); | |
140 | + } | |
141 | + } else { | |
142 | + log.error("教师用户不存在"); | |
143 | + } | |
144 | + } | |
145 | + } | |
146 | + | |
147 | + } catch (Exception e) { | |
148 | + e.printStackTrace(); | |
149 | + } | |
150 | + | |
151 | + return cards; | |
152 | + } | |
153 | + | |
154 | + /** | |
155 | + * 把卡号和权限下发到对应的设备 | |
156 | + * | |
157 | + * @param permissionBean | |
158 | + * @param map | |
159 | + * @param deviceIds | |
160 | + * @param cardNumList | |
161 | + * @param i | |
162 | + * @return | |
163 | + */ | |
164 | + private boolean senPsermiss(PermissionBean permissionBean, Map<Integer, List<WeekTime>> map, List<String> deviceIds, List<String> cardNumList, int i) { | |
165 | + String userType = permissionBean.getUserType(); | |
166 | + | |
167 | + if (deviceIds == null || deviceIds.size() == 0) { | |
168 | + log.error("设备不存在"); | |
169 | + return false; | |
170 | + } | |
78 | 171 | |
79 | - String cardNum = permissionBean.getCardNum(); | |
80 | - List<String> deviceIds = permissionBean.getDeviceIds(); | |
81 | - String userType = permissionBean.getUserType(); | |
82 | - List<WeekDay> weekDays = permissionBean.getWeekDays(); | |
172 | + if (null == cardNumList || cardNumList.size() == 0) { | |
173 | + log.error("卡号为空"); | |
174 | + return false; | |
175 | + } | |
83 | 176 | |
84 | 177 | for (String deviceId : |
85 | 178 | deviceIds) { |
86 | - if (!cmsServer.getIsDeviceOnline(deviceId)){//设备在线 | |
87 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板"); | |
88 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划"); | |
179 | + if (cmsServer.getIsDeviceOnline(deviceId)) {//设备在线 | |
180 | + | |
181 | + for (String cardNum : | |
182 | + cardNumList) { | |
89 | 183 | |
90 | - for (WeekDay weekDay: | |
91 | - weekDays) { | |
184 | + if (!StringUtils.isEmpty(cardNum)) { | |
185 | + cardNum = Long.parseLong(getCard(cardNum), 16) + ""; | |
92 | 186 | |
93 | - List<WeekTime> weekTimes = weekDay.getWeekTimes(); | |
94 | - int weekdayIndex = weekDay.getWeekDay(); | |
187 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板"); | |
188 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划"); | |
95 | 189 | |
96 | - StringBuffer stringBuffer = new StringBuffer();//添加时间集 | |
190 | + for (Map.Entry<Integer, List<WeekTime>> weeKdayMap : | |
191 | + map.entrySet()) { | |
97 | 192 | |
98 | - for (WeekTime weetTime : | |
99 | - weekTimes) { | |
193 | + int week = weeKdayMap.getKey(); | |
194 | + List<WeekTime> weekTimes = weeKdayMap.getValue(); | |
100 | 195 | |
101 | - String weekPlanTimes = HKXmlUtils.getInstance().SetCardWeekPlanTimes(weetTime.getStartTime(),weetTime.getEndTime()); | |
102 | - log.error("weekPlanTimes:{}",weekPlanTimes); | |
103 | - stringBuffer.append(weekPlanTimes); | |
196 | + StringBuffer stringBuffer = new StringBuffer();//添加时间集 | |
197 | + for (WeekTime weekTime : | |
198 | + weekTimes) { | |
199 | + String weekPlanTimes = HKXmlUtils.getInstance().SetCardWeekPlanTimes(weekTime.getStartTime(), weekTime.getEndTime()); | |
200 | +// log.error("weekPlanTimes:{}", weekPlanTimes); | |
201 | + stringBuffer.append(weekPlanTimes); | |
202 | + } | |
104 | 203 | |
204 | + String weekPlanTime = HKXmlUtils.getInstance().SetCardWeekPlanTime(stringBuffer.toString(), "" + week); | |
205 | + String serCardRightCfg = HKXmlUtils.getInstance().SetCardRightCfg(cardNum); | |
206 | +// log.error("serCardRightCfg:{}", serCardRightCfg); | |
207 | + FileUtils.getInstance().writeLogs(weekPlanTime,"设置卡权限周计划时间.txt"); | |
208 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, weekPlanTime, "设置卡权限周计划时间"); | |
209 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, serCardRightCfg, "设置卡权限"); | |
210 | + | |
211 | + } | |
105 | 212 | } |
106 | - String weekPlanTime = HKXmlUtils.getInstance().SetCardWeekPlanTime(stringBuffer.toString(), "" + weekdayIndex); | |
107 | - log.error("weekPlanTime:{}",weekPlanTime); | |
108 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, weekPlanTime, "设置卡权限周计划时间"); | |
109 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardRightCfg(cardNum), "设置卡权限"); | |
213 | + | |
110 | 214 | } |
111 | - }else {//设备不在线 | |
112 | - log.error("deviceId:{}",deviceId+"不在线"); | |
215 | + } else {//设备不在线 | |
216 | + if (i == 0) | |
217 | + HttpUtil.sendPermission2HK(permissionBean); | |
218 | + log.error("deviceId:{}", deviceId + "不在线"); | |
113 | 219 | } |
114 | 220 | |
115 | 221 | } |
116 | - | |
117 | 222 | return true; |
118 | 223 | } |
119 | 224 | |
120 | 225 | |
226 | + private List<String> getCards(String sex, String userType, String schoolId) { | |
227 | + | |
228 | + List<String> cardList = new ArrayList<>(); | |
229 | + | |
230 | + switch (userType) { | |
231 | + case "2"://学生 | |
232 | + String[] sexs = sex.split(","); | |
233 | + List<String> sexList = new ArrayList<>(); | |
234 | + for (int i = 0; i < sexs.length; i++) { | |
235 | + sexList.add(sexs[i]); | |
236 | + } | |
237 | + cardList = userDao.getStudentWiSidAndSex(schoolId, sexList); | |
238 | + break; | |
239 | + } | |
240 | + | |
241 | + return cardList; | |
242 | + } | |
243 | + | |
244 | + | |
245 | + private void initWeedayAndTimes(WeekDay weekDay, Map<Integer, List<WeekTime>> map) { | |
246 | + | |
247 | + String weekDayStr = weekDay.getWeekDay(); | |
248 | + String[] weekDays = weekDayStr.split(","); | |
249 | + | |
250 | + List<WeekTime> weekTimes = weekDay.getWeekTimes(); | |
251 | + | |
252 | + for (int i = 0; i < weekDays.length; i++) { | |
253 | + int weekDayIndex = Integer.parseInt(weekDays[i]); | |
254 | + if (map.containsKey(weekDayIndex)) {//周已经有时间段 | |
255 | + List<WeekTime> weekTimeList = map.get(weekDayIndex); | |
256 | + for (WeekTime wee : | |
257 | + weekTimes) { | |
258 | + weekTimeList.add(wee); | |
259 | + } | |
260 | + map.put(weekDayIndex, weekTimeList); | |
261 | + } else { | |
262 | + List<WeekTime> weekTimes1 = new ArrayList<>(); | |
263 | + weekTimes1.addAll(weekTimes); | |
264 | + map.put(weekDayIndex, weekTimes1); | |
265 | + } | |
266 | + } | |
267 | + | |
268 | + } | |
269 | + | |
270 | + private String getCard(String card) { | |
271 | + | |
272 | + if (card.length() == 8) { | |
273 | + int length = card.length(); | |
274 | + String result = card.substring(length - 2, length) + card.substring(length - 4, length - 2) + card.substring(length - 6, length - 4) | |
275 | + + card.substring(length - 8, length - 6); | |
276 | + return result; | |
277 | + | |
278 | + } else { | |
279 | + System.out.println("卡号位数不对:" + card); | |
280 | + return ""; | |
281 | + } | |
282 | + | |
283 | + } | |
121 | 284 | |
122 | 285 | /** |
123 | 286 | * 调用传图片接口 | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/TeacherBean.java
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +package com.sincere.haikangface.bean; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class TeacherBean implements Serializable { | |
6 | + | |
7 | + private String name; | |
8 | + | |
9 | + private String teacher_num; | |
10 | + | |
11 | + private String num; | |
12 | + | |
13 | + public String getNum() { | |
14 | + return num; | |
15 | + } | |
16 | + | |
17 | + public void setNum(String num) { | |
18 | + this.num = num; | |
19 | + } | |
20 | + | |
21 | + public String getName() { | |
22 | + return name; | |
23 | + } | |
24 | + | |
25 | + public void setName(String name) { | |
26 | + this.name = name; | |
27 | + } | |
28 | + | |
29 | + public String getTeacer_num() { | |
30 | + return teacher_num; | |
31 | + } | |
32 | + | |
33 | + public void setTeacer_num(String teacer_num) { | |
34 | + this.teacher_num = teacer_num; | |
35 | + } | |
36 | +} | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionBean.java
1 | 1 | package com.sincere.haikangface.bean.face; |
2 | 2 | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | + | |
3 | 5 | import java.io.Serializable; |
4 | 6 | import java.util.List; |
5 | 7 | |
... | ... | @@ -7,10 +9,13 @@ public class PermissionBean implements Serializable { |
7 | 9 | |
8 | 10 | private List<String> deviceIds; |
9 | 11 | |
10 | - private String cardNum; | |
12 | + private String schoolId; | |
11 | 13 | |
12 | 14 | private String userType;//学生类型 |
13 | 15 | |
16 | +// @ApiModelProperty("用逗号隔开,1:男,2:女") | |
17 | +// private String sex; | |
18 | + | |
14 | 19 | private List<WeekDay> weekDays; |
15 | 20 | |
16 | 21 | public List<String> getDeviceIds() { |
... | ... | @@ -21,12 +26,12 @@ public class PermissionBean implements Serializable { |
21 | 26 | this.deviceIds = deviceIds; |
22 | 27 | } |
23 | 28 | |
24 | - public String getCardNum() { | |
25 | - return cardNum; | |
29 | + public String getSchoolId() { | |
30 | + return schoolId; | |
26 | 31 | } |
27 | 32 | |
28 | - public void setCardNum(String cardNum) { | |
29 | - this.cardNum = cardNum; | |
33 | + public void setSchoolId(String schoolId) { | |
34 | + this.schoolId = schoolId; | |
30 | 35 | } |
31 | 36 | |
32 | 37 | public String getUserType() { | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/UserAndPermission.java
0 → 100644
... | ... | @@ -0,0 +1,38 @@ |
1 | +package com.sincere.haikangface.bean.face; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.List; | |
5 | + | |
6 | +public class UserAndPermission implements Serializable { | |
7 | + | |
8 | + private int userType; | |
9 | + | |
10 | + private List<WeekDay> weekDays; | |
11 | + | |
12 | + private String schoolId; | |
13 | + | |
14 | + | |
15 | + public int getUserType() { | |
16 | + return userType; | |
17 | + } | |
18 | + | |
19 | + public void setUserType(int userType) { | |
20 | + this.userType = userType; | |
21 | + } | |
22 | + | |
23 | + public List<WeekDay> getWeekDays() { | |
24 | + return weekDays; | |
25 | + } | |
26 | + | |
27 | + public void setWeekDays(List<WeekDay> weekDays) { | |
28 | + this.weekDays = weekDays; | |
29 | + } | |
30 | + | |
31 | + public String getSchoolId() { | |
32 | + return schoolId; | |
33 | + } | |
34 | + | |
35 | + public void setSchoolId(String schoolId) { | |
36 | + this.schoolId = schoolId; | |
37 | + } | |
38 | +} | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/WeekDay.java
1 | 1 | package com.sincere.haikangface.bean.face; |
2 | 2 | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | + | |
3 | 5 | import java.io.Serializable; |
4 | 6 | import java.util.List; |
5 | 7 | |
6 | 8 | public class WeekDay implements Serializable { |
7 | 9 | |
10 | + @ApiModelProperty("用逗号隔开,1:男,2:女") | |
11 | + private String sex; | |
8 | 12 | |
9 | - private int weekDay; | |
13 | + @ApiModelProperty("用逗号隔开,0-6表示周日到周六") | |
14 | + private String weekDay; | |
10 | 15 | |
11 | 16 | private List<WeekTime> weekTimes; |
12 | 17 | |
13 | - public int getWeekDay() { | |
18 | + @ApiModelProperty("教师点名专用") | |
19 | + private String userIds; | |
20 | + | |
21 | + private List<String> deviceIds; | |
22 | + public List<String> getDeviceIds() { | |
23 | + return deviceIds; | |
24 | + } | |
25 | + | |
26 | + public void setDeviceIds(List<String> deviceIds) { | |
27 | + this.deviceIds = deviceIds; | |
28 | + } | |
29 | + | |
30 | + public String getUserIds() { | |
31 | + return userIds; | |
32 | + } | |
33 | + | |
34 | + public void setUserIds(String userIds) { | |
35 | + this.userIds = userIds; | |
36 | + } | |
37 | + | |
38 | + public String getWeekDay() { | |
14 | 39 | return weekDay; |
15 | 40 | } |
16 | 41 | |
17 | - public void setWeekDay(int weekDay) { | |
42 | + public void setWeekDay(String weekDay) { | |
18 | 43 | this.weekDay = weekDay; |
19 | 44 | } |
20 | 45 | |
... | ... | @@ -25,4 +50,12 @@ public class WeekDay implements Serializable { |
25 | 50 | public void setWeekTimes(List<WeekTime> weekTimes) { |
26 | 51 | this.weekTimes = weekTimes; |
27 | 52 | } |
53 | + | |
54 | + public String getSex() { | |
55 | + return sex; | |
56 | + } | |
57 | + | |
58 | + public void setSex(String sex) { | |
59 | + this.sex = sex; | |
60 | + } | |
28 | 61 | } | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java
1 | 1 | package com.sincere.haikangface.control; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSON; | |
3 | 4 | import com.sincere.haikangface.CMSServer; |
4 | 5 | import com.sincere.haikangface.async.SendUserAsync; |
5 | 6 | import com.sincere.haikangface.bean.Images2Ddevices; |
6 | 7 | import com.sincere.haikangface.bean.StudentBean; |
7 | 8 | import com.sincere.haikangface.bean.UploadBean; |
9 | +import com.sincere.haikangface.bean.face.PermissionBean; | |
8 | 10 | import com.sincere.haikangface.dao.UserDao; |
9 | 11 | import com.sincere.haikangface.utils.CompressPic; |
10 | 12 | import com.sincere.haikangface.utils.FileUtils; |
... | ... | @@ -12,9 +14,11 @@ import com.sincere.haikangface.utils.SendRecoderUtils; |
12 | 14 | import com.sincere.haikangface.xiananDao.SendRecordDao; |
13 | 15 | import io.swagger.annotations.Api; |
14 | 16 | import io.swagger.annotations.ApiOperation; |
17 | +import lombok.extern.slf4j.Slf4j; | |
15 | 18 | import org.slf4j.Logger; |
16 | 19 | import org.slf4j.LoggerFactory; |
17 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
21 | +import org.springframework.util.StringUtils; | |
18 | 22 | import org.springframework.web.bind.annotation.*; |
19 | 23 | import org.springframework.web.multipart.MultipartFile; |
20 | 24 | |
... | ... | @@ -26,6 +30,7 @@ import java.util.*; |
26 | 30 | @RestController |
27 | 31 | @Api("文件管理器") |
28 | 32 | @RequestMapping("file/*") |
33 | +@Slf4j | |
29 | 34 | public class FileControl { |
30 | 35 | |
31 | 36 | @Autowired |
... | ... | @@ -44,6 +49,16 @@ public class FileControl { |
44 | 49 | |
45 | 50 | Queue<UploadBean> uploadBeanQueue = new LinkedList<>(); |
46 | 51 | |
52 | + @RequestMapping(value = "sendPermiss", method = RequestMethod.POST) | |
53 | + @ApiOperation("下发权限给设备") | |
54 | + public boolean sendPermiss(@RequestBody PermissionBean permissionBean) { | |
55 | + log.error("permissionBean:{}", JSON.toJSONString(permissionBean)); | |
56 | + if (!StringUtils.isEmpty(permissionBean)) { | |
57 | + return sendUserAsync.sendPermiss(permissionBean,1); | |
58 | + } | |
59 | + return false; | |
60 | + } | |
61 | + | |
47 | 62 | @RequestMapping(method = RequestMethod.POST, value = "uploadImg") |
48 | 63 | public String uploadImg(@RequestParam("file") MultipartFile file, @RequestParam("card") String card |
49 | 64 | , @RequestParam("name") String name, @RequestParam("deviceId") String deviceId, @RequestParam("startTime") String startTime, | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
... | ... | @@ -2,13 +2,16 @@ package com.sincere.haikangface.control; |
2 | 2 | |
3 | 3 | //import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
4 | 4 | |
5 | +import com.alibaba.fastjson.JSON; | |
5 | 6 | import com.sincere.haikangface.bean.Images2Ddevices; |
6 | 7 | //import com.sincere.haikangface.utils.BaiduApiUtiols; |
7 | 8 | import com.sincere.haikangface.CMSServer; |
8 | 9 | import com.sincere.haikangface.async.SendUserAsync; |
9 | 10 | import com.sincere.haikangface.bean.StudentBean; |
10 | 11 | import com.sincere.haikangface.bean.StudentInfo; |
12 | +import com.sincere.haikangface.bean.TeacherBean; | |
11 | 13 | import com.sincere.haikangface.bean.face.PermissionBean; |
14 | +import com.sincere.haikangface.bean.face.UserAndPermission; | |
12 | 15 | import com.sincere.haikangface.dao.UserDao; |
13 | 16 | import com.sincere.haikangface.fegin.HaikangfaceFegin; |
14 | 17 | import com.sincere.haikangface.utils.*; |
... | ... | @@ -17,16 +20,20 @@ import io.swagger.annotations.Api; |
17 | 20 | import io.swagger.annotations.ApiImplicitParam; |
18 | 21 | import io.swagger.annotations.ApiImplicitParams; |
19 | 22 | import io.swagger.annotations.ApiOperation; |
23 | +import lombok.extern.slf4j.Slf4j; | |
24 | +import org.apache.poi.util.StringUtil; | |
20 | 25 | import org.slf4j.Logger; |
21 | 26 | import org.slf4j.LoggerFactory; |
22 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 28 | import org.springframework.http.MediaType; |
24 | 29 | import org.springframework.util.StringUtils; |
25 | 30 | import org.springframework.web.bind.annotation.*; |
31 | +import org.springframework.web.client.RestTemplate; | |
26 | 32 | import org.springframework.web.multipart.MultipartFile; |
27 | 33 | |
28 | 34 | import java.io.*; |
29 | 35 | import java.text.SimpleDateFormat; |
36 | +import java.util.ArrayList; | |
30 | 37 | import java.util.Calendar; |
31 | 38 | import java.util.Date; |
32 | 39 | import java.util.List; |
... | ... | @@ -34,6 +41,7 @@ import java.util.List; |
34 | 41 | @RestController |
35 | 42 | @RequestMapping(value = "/facereco/*", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
36 | 43 | @Api("用户控制") |
44 | +@Slf4j | |
37 | 45 | public class UserControl { |
38 | 46 | |
39 | 47 | @Autowired |
... | ... | @@ -58,20 +66,47 @@ public class UserControl { |
58 | 66 | @RequestMapping(value = "sendPermiss", method = RequestMethod.POST) |
59 | 67 | @ApiOperation("下发权限给设备") |
60 | 68 | public boolean sendPermiss(@RequestBody PermissionBean permissionBean) { |
61 | - | |
62 | - if (!StringUtils.isEmpty(permissionBean)) { | |
63 | - return sendUserAsync.sendPermiss(permissionBean); | |
69 | + log.error("permissionBean:{}", JSON.toJSONString(permissionBean)); | |
70 | + if (!StringUtils.isEmpty(permissionBean.getDeviceIds())) { | |
71 | +// List<String> cardNumList = userDao.getStudentCardsWidthSchoolId(permissionBean.getSchoolId()); | |
72 | + return sendUserAsync.sendPermiss(permissionBean, 0); | |
64 | 73 | } |
65 | 74 | return false; |
66 | 75 | } |
67 | 76 | |
77 | + @RequestMapping(value = "sendUsersAndPermiss", method = RequestMethod.POST) | |
78 | + @ApiOperation("下发指定教师用户权限给设备") | |
79 | + public boolean sendUsersAndPermiss(@RequestBody UserAndPermission userAndPermission) { | |
80 | + log.error("sendUsersAndPermiss:{}", JSON.toJSONString(userAndPermission)); | |
81 | + FileUtils.getInstance().writeLogs(JSON.toJSONString(userAndPermission),"下发指定教师用户权限给设备.txt"); | |
82 | + PermissionBean permissionBean = new PermissionBean(); | |
83 | + permissionBean.setSchoolId(userAndPermission.getSchoolId()); | |
84 | + permissionBean.setUserType(String.valueOf(userAndPermission.getUserType())); | |
85 | + permissionBean.setWeekDays(userAndPermission.getWeekDays()); | |
86 | + return sendUserAsync.sendPermiss(permissionBean, 0); | |
87 | + } | |
88 | + | |
89 | + | |
90 | + @RequestMapping(value = "isTeacher", method = RequestMethod.GET) | |
91 | + @ApiOperation("测试教师点名") | |
92 | + public void isTeacher(@RequestParam("deviceId") String deviceId, @RequestParam("cardNo") String cardNo) { | |
93 | + try { | |
94 | + cmsServer.isTeacher(cardNo,deviceId); | |
95 | + }catch (Exception e){ | |
96 | + e.printStackTrace(); | |
97 | + } | |
98 | + } | |
99 | + | |
68 | 100 | |
69 | 101 | @RequestMapping(value = "sendStuCardAndImg", method = RequestMethod.GET) |
70 | 102 | @ApiOperation("下发人脸给设备") |
71 | 103 | public boolean sendCardAndImg(@RequestParam("filePath") String filePath, @RequestParam("card") String card |
72 | 104 | , @RequestParam("name") String name, @RequestParam("deviceId") String deviceId, @RequestParam("startTime") String startTime, |
73 | 105 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { |
106 | + return sendImg2Device(filePath, card, name, deviceId, userType); | |
107 | + } | |
74 | 108 | |
109 | + private boolean sendImg2Device(String filePath, String card, String name, String deviceId, String userType) { | |
75 | 110 | try { |
76 | 111 | |
77 | 112 | if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
... | ... | @@ -222,4 +222,28 @@ public interface UserDao { |
222 | 222 | @Insert("insert into CW_StuTemperatureReocrd values (#{UserId},#{StudentId},#{Name},#{ClassId},#{ClassName},#{Temperature},#{Type},#{SchoolId},#{Intime})") |
223 | 223 | void addWGTem(@Param("UserId") String UserId, @Param("StudentId") String StudentId, @Param("Name") String Name, @Param("ClassId") String ClassId, |
224 | 224 | @Param("ClassName") String ClassName, @Param("Temperature") String Temperature, @Param("Type") String Type, @Param("SchoolId") String SchoolId, @Param("Intime") String Intime); |
225 | + | |
226 | + @Select("select student_num from SZ_V_School_Student where school_id = #{schoolId} and student_num<>''") | |
227 | + List<String> getStudentCardsWidthSchoolId(@Param("schoolId") String schoolId); | |
228 | + | |
229 | + @Select("select student_num from SZ_V_School_Teacher where school_id = #{schoolId} and student_num<>''") | |
230 | + List<String> getTeaCardsWidthSchoolId(@Param("schoolId") String schoolId); | |
231 | + | |
232 | + @Select("select Top(1) teacher_num from SZ_V_School_Teacher where user_id = #{userId}") | |
233 | + String getTeaCardWithUserId(@Param("userId") String userId); | |
234 | + | |
235 | + | |
236 | + @Select("select student_num from SZ_V_School_Student where user_id = #{userId}") | |
237 | + String getStudentCardWithUserId(@Param("userId") String userId); | |
238 | + | |
239 | + @Select("select Top(1) * from SZ_V_School_Teacher where user_id = #{userId} and teacher_num<>''") | |
240 | + TeacherBean getTeacherWithUserId(@Param("userId") String userId); | |
241 | + | |
242 | + | |
243 | + List<String> getStudentWiSidAndSex(@Param("schoolId")String schoolId , @Param("sexs")List<String> sexs); | |
244 | + | |
245 | + | |
246 | + List<String> getDeviceRoomRelation(@Param("clint_id")String clint_id); | |
247 | + | |
248 | + | |
225 | 249 | } | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java
... | ... | @@ -118,7 +118,7 @@ public class AlarmUtils { |
118 | 118 | */ |
119 | 119 | private void shijian(String minorType, String deviceID, String cardNo, String time, String picDataUrl, String currTemperature) { |
120 | 120 | String content = ""; |
121 | - System.out.println("=-=============================minorType:" + minorType); | |
121 | +// System.out.println("=-=============================minorType:" + minorType); | |
122 | 122 | switch (minorType) { |
123 | 123 | case "0x01"://合法卡认证通过 |
124 | 124 | content = "合法卡认证通过"; | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/CompressPic.java
... | ... | @@ -54,6 +54,13 @@ public class CompressPic { |
54 | 54 | try { |
55 | 55 | File targetFile = new File(targetPath); |
56 | 56 | if (!targetFile.exists()) targetFile.createNewFile(); |
57 | + | |
58 | + if (width>height){ | |
59 | + int width1 = width; | |
60 | + width = height; | |
61 | + height = width1; | |
62 | + } | |
63 | + | |
57 | 64 | BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
58 | 65 | tag.getGraphics().drawImage(bufferedImage, 0, 0, width, height, null); // 绘制缩小后的图 |
59 | 66 | FileOutputStream deskImage = new FileOutputStream(targetPath); // 输出到文件流 | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HKXmlUtils.java
... | ... | @@ -151,7 +151,7 @@ public class HKXmlUtils { |
151 | 151 | * @return |
152 | 152 | */ |
153 | 153 | public String SetCardWeekPlanTimes(String startTime, String endTime) { |
154 | - return "<startTime>" + startTime + "</startTime>\n" + | |
155 | - "<endTime>" + endTime + "</endTime>\n"; | |
154 | + return "<startTime>" + startTime.trim() + "</startTime>\n" + | |
155 | + "<endTime>" + endTime.trim() + "</endTime>\n"; | |
156 | 156 | } |
157 | 157 | } | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java
1 | 1 | package com.sincere.haikangface.utils; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.sincere.haikangface.bean.face.PermissionBean; | |
3 | 5 | import org.springframework.core.io.FileSystemResource; |
4 | 6 | import org.springframework.http.HttpEntity; |
5 | 7 | import org.springframework.http.HttpHeaders; |
... | ... | @@ -162,4 +164,34 @@ public class HttpUtil { |
162 | 164 | return restTemplate.getForObject(url, String.class).equals("1"); |
163 | 165 | } |
164 | 166 | |
167 | + | |
168 | + public static void sendPermission2HK(PermissionBean permissionBean) { | |
169 | + try { | |
170 | + | |
171 | + String url = "http://120.26.116.253:8089/file/sendPermiss"; | |
172 | + | |
173 | + if (null != permissionBean) { | |
174 | + | |
175 | + RestTemplate restTemplate = new RestTemplate(); | |
176 | + | |
177 | + HttpHeaders headers = new HttpHeaders(); | |
178 | + | |
179 | + MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE); | |
180 | + | |
181 | + headers.setContentType(mediaType); | |
182 | + | |
183 | + HttpEntity<PermissionBean> httpEntity = new HttpEntity<>(permissionBean, headers); | |
184 | + | |
185 | + System.out.println("PermissionBean:"+JSON.toJSONString(permissionBean)); | |
186 | + | |
187 | + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | |
188 | + | |
189 | + System.out.println("responseEntity:" + responseEntity.getBody()); | |
190 | + | |
191 | + } | |
192 | + } catch (Exception e) { | |
193 | + e.printStackTrace(); | |
194 | + } | |
195 | + } | |
196 | + | |
165 | 197 | } | ... | ... |
cloud/haikangface/src/main/resources/application.yaml
... | ... | @@ -10,10 +10,10 @@ spring: |
10 | 10 | password: RQminVCJota3H1u8bBYH |
11 | 11 | jdbc-url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus |
12 | 12 | driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
13 | - # username: SZJXTUSER | |
14 | - # password: xst200919 | |
15 | - # jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=SmartCampusSZ | |
16 | - # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
13 | +# username: SZJXTUSER | |
14 | +# password: xst200919 | |
15 | +# jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=SmartCampusSZ | |
16 | +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
17 | 17 | xiaoan: |
18 | 18 | jdbc-url: jdbc:sqlserver://116.62.241.27:33419;database=xiaoanhxy |
19 | 19 | username: szjxtuser | ... | ... |
cloud/haikangface/src/main/resources/mapper/usermapper.xml
... | ... | @@ -9,4 +9,17 @@ |
9 | 9 | <!--and studentcode = #{studentcode}--> |
10 | 10 | <!--</select>--> |
11 | 11 | |
12 | + <select id="getStudentWiSidAndSex" resultType="java.lang.String"> | |
13 | + | |
14 | + select student_num from SZ_V_School_Student where school_id = #{schoolId} and sex in | |
15 | + <foreach collection="sexs" item="sex" index="index" open="(" separator="," close=")"> | |
16 | + #{sex} | |
17 | + </foreach> | |
18 | + | |
19 | + </select> | |
20 | + | |
21 | + <select id="getDeviceRoomRelation" resultType="java.lang.String"> | |
22 | + select clint_id from SZ_DeviceRoomRelation where clint_id = #{clint_id}; | |
23 | + </select> | |
24 | + | |
12 | 25 | </mapper> | ... | ... |
cloud/pom.xml
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | <!-- <module>mypulsar</module>--> |
41 | 41 | <!-- <module>weigeng</module>--> |
42 | 42 | <!-- <module>independence</module>--> |
43 | - <!-- <module>quartz</module>--> | |
43 | + <module>quartz</module> | |
44 | 44 | <!-- <module>zkAttendance</module>--> |
45 | 45 | <module>user_search</module> |
46 | 46 | <module>fIle-center</module> | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/Swagger2.java
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +package com.sincere.quartz; | |
2 | + | |
3 | +import org.springframework.context.annotation.Bean; | |
4 | +import org.springframework.context.annotation.Configuration; | |
5 | +import springfox.documentation.builders.ApiInfoBuilder; | |
6 | +import springfox.documentation.builders.PathSelectors; | |
7 | +import springfox.documentation.builders.RequestHandlerSelectors; | |
8 | +import springfox.documentation.service.ApiInfo; | |
9 | +import springfox.documentation.spi.DocumentationType; | |
10 | +import springfox.documentation.spring.web.plugins.Docket; | |
11 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | |
12 | + | |
13 | +@Configuration | |
14 | +@EnableSwagger2 | |
15 | +public class Swagger2 { | |
16 | + | |
17 | + @Bean | |
18 | + public Docket createRestApi() { | |
19 | + return new Docket(DocumentationType.SWAGGER_2) | |
20 | + .apiInfo(apiInfo()) | |
21 | + .select() | |
22 | + .apis(RequestHandlerSelectors.basePackage("com.sincere.quartz.control")) | |
23 | + .paths(PathSelectors.any()) | |
24 | + .build(); | |
25 | + } | |
26 | + | |
27 | + private ApiInfo apiInfo() { | |
28 | + return new ApiInfoBuilder() | |
29 | + .title("大华人脸接口") | |
30 | + .description("") | |
31 | + .termsOfServiceUrl("") | |
32 | + .version("1.0") | |
33 | + .build(); | |
34 | + } | |
35 | + | |
36 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/control/FaceUnifyController.java
0 → 100644
... | ... | @@ -0,0 +1,22 @@ |
1 | +package com.sincere.quartz.control; | |
2 | + | |
3 | +import io.swagger.annotations.ApiOperation; | |
4 | +import lombok.extern.slf4j.Slf4j; | |
5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
6 | +import org.springframework.web.bind.annotation.RequestMethod; | |
7 | +import org.springframework.web.bind.annotation.RestController; | |
8 | + | |
9 | +@RestController | |
10 | +@RequestMapping("faceUnify/*") | |
11 | +@Slf4j | |
12 | +public class FaceUnifyController { | |
13 | + | |
14 | + | |
15 | + @RequestMapping(value = "sendPermission",method = RequestMethod.GET) | |
16 | + @ApiOperation("添加/编辑/删除权限") | |
17 | + public void sendPermission(){ | |
18 | + log.error("ssssssssssssssssssssssssssssssssssssssssss:{}","2222222222222"); | |
19 | + } | |
20 | + | |
21 | + | |
22 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/BindPushJob.java
1 | -package com.sincere.quartz.job; | |
2 | - | |
3 | -import com.sincere.common.dto.smartCampus.BindPushDto; | |
4 | -import com.sincere.common.dto.smartCampus.ParentDto; | |
5 | -import com.sincere.common.enums.PushTypeEnums; | |
6 | -import com.sincere.common.util.DateUtils; | |
7 | -import com.sincere.quartz.feign.ScFeign; | |
8 | -import com.sincere.quartz.model.ShortMsg; | |
9 | -import com.sincere.quartz.service.SmsService; | |
10 | -import org.apache.commons.lang3.StringUtils; | |
11 | -import org.slf4j.Logger; | |
12 | -import org.slf4j.LoggerFactory; | |
13 | -import org.springframework.beans.factory.annotation.Autowired; | |
14 | -import org.springframework.scheduling.annotation.Scheduled; | |
15 | -import org.springframework.stereotype.Service; | |
16 | - | |
17 | -import java.util.Date; | |
18 | -import java.util.HashMap; | |
19 | -import java.util.List; | |
20 | -import java.util.Map; | |
21 | - | |
22 | -/** | |
23 | - * 用户注册激活提醒 | |
24 | - * | |
25 | - * @author chen | |
26 | - * @version 1.0 | |
27 | - * @date 2019/12/10 0010 8:31 | |
28 | - */ | |
29 | -@Service | |
30 | -public class BindPushJob { | |
31 | - | |
32 | - private Logger logger = LoggerFactory.getLogger(BindPushJob.class); | |
33 | - | |
34 | - | |
35 | - @Autowired | |
36 | - ScFeign scFeign; | |
37 | - | |
38 | - @Autowired | |
39 | - SmsService smsService; | |
40 | - | |
41 | - private static Map<String, String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误 | |
42 | - | |
43 | - @Scheduled(cron = "0 0-59 * * * ? ") | |
44 | - public void bindPush() { | |
45 | - Date nowDate = new Date(); | |
46 | - List<BindPushDto> schoolList = scFeign.selectBindPushSchool(); | |
47 | - for (BindPushDto school : schoolList) { | |
48 | - if (school.getBeginDate().compareTo(nowDate) <= 0 && school.getEndDate().compareTo(nowDate) >= 0) { | |
49 | - String lastDate = intervalDaysMap.get(school.getSchoolId() + "_" + school.getType()); | |
50 | - if (StringUtils.isBlank(lastDate)) { | |
51 | - //下发推送 | |
52 | - bindPush(school, nowDate); | |
53 | - } else { | |
54 | - int day = DateUtils.getDateDifference(nowDate, DateUtils.string2Date(lastDate, DateUtils.format1), "day"); | |
55 | - if (day == school.getIntervalDays() + 1) { | |
56 | - //下发推送 | |
57 | - bindPush(school, nowDate); | |
58 | - } | |
59 | - } | |
60 | - } | |
61 | - } | |
62 | - } | |
63 | - | |
64 | - private void bindPush(BindPushDto bindPushDto, Date nowDate) { | |
65 | - if (bindPushDto.getPushTime().equals(DateUtils.date2String(nowDate, DateUtils.format4))) { | |
66 | - intervalDaysMap.put(bindPushDto.getSchoolId() + "_" + bindPushDto.getType(), DateUtils.date2String(nowDate, DateUtils.format1)); | |
67 | - //未关注 | |
68 | - List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId()); | |
69 | - logger.info(bindPushDto.getSchoolName() + "未关注人数" + unFollowList.size()); | |
70 | - for (ParentDto parentDto : unFollowList) { | |
71 | - sendMessage(parentDto, bindPushDto.getMsg()); | |
72 | - } | |
73 | - //未绑定 | |
74 | - List<ParentDto> unBindList = scFeign.selectNotBind(bindPushDto.getSchoolId(), getThirdType(bindPushDto.getType())); | |
75 | - logger.info(bindPushDto.getSchoolName() + "未绑定人数" + unBindList.size()); | |
76 | - for (ParentDto parentDto : unBindList) { | |
77 | - sendMessage(parentDto, bindPushDto.getMsg()); | |
78 | - } | |
79 | - } | |
80 | - } | |
81 | - | |
82 | - private void sendMessage(ParentDto parentDto, String message) { | |
83 | - //手机号为空 | |
84 | - if (StringUtils.isNotBlank(parentDto.getMobile())) { | |
85 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
86 | - ShortMsg shortMsg = new ShortMsg(); | |
87 | - shortMsg.setTableName("smsNew" + tableSuffix); | |
88 | - shortMsg.setSchoolId(parentDto.getSchoolId()); | |
89 | - shortMsg.setMobile(parentDto.getMobile()); | |
90 | - shortMsg.setMsg(message); | |
91 | - smsService.insertSMS(shortMsg); | |
92 | - logger.info("----学校Id---" + parentDto.getSchoolId() + "----手机号----" + parentDto.getMobile() + "---" + message); | |
93 | - } | |
94 | - } | |
95 | - | |
96 | - // 0是企业号,1是钉钉 | |
97 | - private int getThirdType(int type) { | |
98 | - if (type == 0) { | |
99 | - return PushTypeEnums.QIYEHAO.getType(); | |
100 | - } else { | |
101 | - return PushTypeEnums.DING.getType(); | |
102 | - } | |
103 | - } | |
104 | - | |
105 | -} | |
1 | +//package com.sincere.quartz.job; | |
2 | +// | |
3 | +//import com.sincere.common.dto.smartCampus.BindPushDto; | |
4 | +//import com.sincere.common.dto.smartCampus.ParentDto; | |
5 | +//import com.sincere.common.enums.PushTypeEnums; | |
6 | +//import com.sincere.common.util.DateUtils; | |
7 | +//import com.sincere.quartz.feign.ScFeign; | |
8 | +//import com.sincere.quartz.model.ShortMsg; | |
9 | +//import com.sincere.quartz.service.SmsService; | |
10 | +//import org.apache.commons.lang3.StringUtils; | |
11 | +//import org.slf4j.Logger; | |
12 | +//import org.slf4j.LoggerFactory; | |
13 | +//import org.springframework.beans.factory.annotation.Autowired; | |
14 | +//import org.springframework.scheduling.annotation.Scheduled; | |
15 | +//import org.springframework.stereotype.Service; | |
16 | +// | |
17 | +//import java.util.Date; | |
18 | +//import java.util.HashMap; | |
19 | +//import java.util.List; | |
20 | +//import java.util.Map; | |
21 | +// | |
22 | +///** | |
23 | +// * 用户注册激活提醒 | |
24 | +// * | |
25 | +// * @author chen | |
26 | +// * @version 1.0 | |
27 | +// * @date 2019/12/10 0010 8:31 | |
28 | +// */ | |
29 | +//@Service | |
30 | +//public class BindPushJob { | |
31 | +// | |
32 | +// private Logger logger = LoggerFactory.getLogger(BindPushJob.class); | |
33 | +// | |
34 | +// | |
35 | +// @Autowired | |
36 | +// ScFeign scFeign; | |
37 | +// | |
38 | +// @Autowired | |
39 | +// SmsService smsService; | |
40 | +// | |
41 | +// private static Map<String, String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误 | |
42 | +// | |
43 | +// @Scheduled(cron = "0 0-59 * * * ? ") | |
44 | +// public void bindPush() { | |
45 | +// Date nowDate = new Date(); | |
46 | +// List<BindPushDto> schoolList = scFeign.selectBindPushSchool(); | |
47 | +// for (BindPushDto school : schoolList) { | |
48 | +// if (school.getBeginDate().compareTo(nowDate) <= 0 && school.getEndDate().compareTo(nowDate) >= 0) { | |
49 | +// String lastDate = intervalDaysMap.get(school.getSchoolId() + "_" + school.getType()); | |
50 | +// if (StringUtils.isBlank(lastDate)) { | |
51 | +// //下发推送 | |
52 | +// bindPush(school, nowDate); | |
53 | +// } else { | |
54 | +// int day = DateUtils.getDateDifference(nowDate, DateUtils.string2Date(lastDate, DateUtils.format1), "day"); | |
55 | +// if (day == school.getIntervalDays() + 1) { | |
56 | +// //下发推送 | |
57 | +// bindPush(school, nowDate); | |
58 | +// } | |
59 | +// } | |
60 | +// } | |
61 | +// } | |
62 | +// } | |
63 | +// | |
64 | +// private void bindPush(BindPushDto bindPushDto, Date nowDate) { | |
65 | +// if (bindPushDto.getPushTime().equals(DateUtils.date2String(nowDate, DateUtils.format4))) { | |
66 | +// intervalDaysMap.put(bindPushDto.getSchoolId() + "_" + bindPushDto.getType(), DateUtils.date2String(nowDate, DateUtils.format1)); | |
67 | +// //未关注 | |
68 | +// List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId()); | |
69 | +// logger.info(bindPushDto.getSchoolName() + "未关注人数" + unFollowList.size()); | |
70 | +// for (ParentDto parentDto : unFollowList) { | |
71 | +// sendMessage(parentDto, bindPushDto.getMsg()); | |
72 | +// } | |
73 | +// //未绑定 | |
74 | +// List<ParentDto> unBindList = scFeign.selectNotBind(bindPushDto.getSchoolId(), getThirdType(bindPushDto.getType())); | |
75 | +// logger.info(bindPushDto.getSchoolName() + "未绑定人数" + unBindList.size()); | |
76 | +// for (ParentDto parentDto : unBindList) { | |
77 | +// sendMessage(parentDto, bindPushDto.getMsg()); | |
78 | +// } | |
79 | +// } | |
80 | +// } | |
81 | +// | |
82 | +// private void sendMessage(ParentDto parentDto, String message) { | |
83 | +// //手机号为空 | |
84 | +// if (StringUtils.isNotBlank(parentDto.getMobile())) { | |
85 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
86 | +// ShortMsg shortMsg = new ShortMsg(); | |
87 | +// shortMsg.setTableName("smsNew" + tableSuffix); | |
88 | +// shortMsg.setSchoolId(parentDto.getSchoolId()); | |
89 | +// shortMsg.setMobile(parentDto.getMobile()); | |
90 | +// shortMsg.setMsg(message); | |
91 | +// smsService.insertSMS(shortMsg); | |
92 | +// logger.info("----学校Id---" + parentDto.getSchoolId() + "----手机号----" + parentDto.getMobile() + "---" + message); | |
93 | +// } | |
94 | +// } | |
95 | +// | |
96 | +// // 0是企业号,1是钉钉 | |
97 | +// private int getThirdType(int type) { | |
98 | +// if (type == 0) { | |
99 | +// return PushTypeEnums.QIYEHAO.getType(); | |
100 | +// } else { | |
101 | +// return PushTypeEnums.DING.getType(); | |
102 | +// } | |
103 | +// } | |
104 | +// | |
105 | +//} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
1 | -package com.sincere.quartz.job; | |
2 | - | |
3 | -import com.alibaba.fastjson.JSONArray; | |
4 | -import com.alibaba.fastjson.JSONObject; | |
5 | -import com.sincere.common.dto.smartCampus.*; | |
6 | -import com.sincere.common.enums.PushTypeEnums; | |
7 | -import com.sincere.common.util.DateUtils; | |
8 | -import com.sincere.common.util.HttpClientUtils; | |
9 | -import com.sincere.quartz.enums.KqTypeEnums; | |
10 | -import com.sincere.quartz.enums.TypeEnums; | |
11 | -import com.sincere.quartz.feign.ScFeign; | |
12 | -import com.sincere.quartz.model.DingSms; | |
13 | -import com.sincere.quartz.model.ShortMsg; | |
14 | -import com.sincere.quartz.model.WeChatSms; | |
15 | -import com.sincere.quartz.service.ManagerService; | |
16 | -import com.sincere.quartz.service.SmsService; | |
17 | -import org.apache.commons.lang3.StringUtils; | |
18 | -import org.slf4j.Logger; | |
19 | -import org.slf4j.LoggerFactory; | |
20 | -import org.springframework.beans.factory.annotation.Autowired; | |
21 | -import org.springframework.scheduling.annotation.Scheduled; | |
22 | -import org.springframework.stereotype.Service; | |
23 | - | |
24 | -import java.math.BigDecimal; | |
25 | -import java.util.*; | |
26 | - | |
27 | -/** | |
28 | - * 考勤任务推送调用 | |
29 | - * 主要推送盯盯以及企业号 | |
30 | - * | |
31 | - * @author chen | |
32 | - * @version 1.0 | |
33 | - * @date 2019/11/27 0027 17:05 | |
34 | - */ | |
35 | -@Service | |
36 | -public class KQJob { | |
37 | - | |
38 | - private Logger logger = LoggerFactory.getLogger(KQJob.class); | |
39 | - | |
40 | - @Autowired | |
41 | - ScFeign scFeign; | |
42 | - | |
43 | - @Autowired | |
44 | - SmsService smsService; | |
45 | - | |
46 | - @Autowired | |
47 | - ManagerService managerService; | |
48 | - | |
49 | - private static String iotUrl = "http://60.190.202.57:8035"; | |
50 | - | |
51 | - private static String date; | |
52 | - private static Map<String, String> map = new HashMap<>(); //学校 考勤推送map | |
53 | - | |
54 | - private static String alarmDate; | |
55 | - private static Map<String, String> alarmMap = new HashMap<>(); //考勤告警推送map | |
56 | - private static Map<String, BigDecimal> templateMap = new HashMap<>(); // 考勤比例 | |
57 | - | |
58 | - private static List<String> opexList; | |
59 | - private static String integration; | |
60 | - | |
61 | - static { | |
62 | - opexList = new ArrayList<>(); | |
63 | - opexList.add("15857566147"); //王汉栋 | |
64 | - opexList.add("13858485977"); //王楠彬 | |
65 | - | |
66 | - integration = "18767117554"; //林炜 | |
67 | - } | |
68 | - | |
69 | - @Scheduled(cron = "0 0-59 * * * ? ") | |
70 | - public void kaoQing() { | |
71 | - String now = DateUtils.date2String(new Date(), DateUtils.format1); | |
72 | - if (StringUtils.isBlank(date)) { | |
73 | - initMap(); | |
74 | - date = now; | |
75 | - } | |
76 | - if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(date)) { | |
77 | - initMap(); | |
78 | - date = DateUtils.date2String(new Date(), DateUtils.format1); | |
79 | - } | |
80 | - //开始过滤数据 推送 | |
81 | - List<String> keyList = new ArrayList<>(); | |
82 | - for (Map.Entry<String, String> entity : map.entrySet()) { | |
83 | - String endTime = entity.getValue().split("_")[1]; | |
84 | - if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2 | |
85 | - && DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") < 5) { | |
86 | - String key = entity.getKey(); | |
87 | - String[] messageArray = key.split("_"); | |
88 | - if (messageArray[2].contains(PushTypeEnums.QIYEHAO.getType() + "")) { | |
89 | - logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]); | |
90 | - weChatBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue()); | |
91 | - } | |
92 | - if (messageArray[2].contains(PushTypeEnums.DING.getType() + "")) { | |
93 | - logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1])); | |
94 | - dingBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue()); | |
95 | - } | |
96 | - keyList.add(key); | |
97 | - } | |
98 | - } | |
99 | - for (String key : keyList) { | |
100 | - map.remove(key); | |
101 | - } | |
102 | - } | |
103 | - | |
104 | - @Scheduled(cron = "0 0-59 * * * ? ") | |
105 | - public void alarmKaoQing() { | |
106 | - String now = DateUtils.date2String(new Date(), DateUtils.format1); | |
107 | - if (StringUtils.isBlank(alarmDate)) { | |
108 | - initAlarmMap(); | |
109 | - alarmDate = now; | |
110 | - } | |
111 | - if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(alarmDate)) { | |
112 | - initAlarmMap(); | |
113 | - alarmDate = DateUtils.date2String(new Date(), DateUtils.format1); | |
114 | - } | |
115 | - //开始过滤数据 推送 | |
116 | - List<String> keyList = new ArrayList<>(); | |
117 | - for (Map.Entry<String, String> entity : alarmMap.entrySet()) { | |
118 | - String endTime = entity.getValue().split("_")[1]; | |
119 | - if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2 | |
120 | - ) { | |
121 | - String key = entity.getKey(); | |
122 | - keyList.add(key); | |
123 | - //alarm(entity); //告警 | |
124 | - //insertIOT(entity); //iot | |
125 | - } | |
126 | - } | |
127 | - for (String key : keyList) { | |
128 | - map.remove(key); | |
129 | - } | |
130 | - } | |
131 | - | |
132 | - private void initAlarmMap() { | |
133 | - alarmMap = new HashMap<>(); | |
134 | - List<TemplateDto> list = scFeign.getAllTemplateAlarm(); | |
135 | - logger.info(("------考勤告警模板------")); | |
136 | - for (TemplateDto templateDto : list) { | |
137 | - String config = templateDto.getConfig(); | |
138 | - String[] array = config.split("<Template"); | |
139 | - for (int i = 1; i < array.length; i++) { | |
140 | - try { | |
141 | - String msg = array[i]; | |
142 | - String beginTime = msg.substring(msg.indexOf("BeginTime") + 11, msg.indexOf("BeginTime") + 16); | |
143 | - String endTime = msg.substring(msg.indexOf("EndTime") + 9, msg.indexOf("EndTime") + 14); | |
144 | - String templateId = msg.substring(msg.indexOf("TemplateID") + 12, msg.indexOf("TemplateID") + 22); | |
145 | - String Week = msg.substring(msg.indexOf("Week") + 6, msg.indexOf("Week") + 19); | |
146 | - String type = msg.substring(msg.indexOf("Type") + 6, msg.indexOf("Type") + 8); | |
147 | - type = type.replace("\"", ""); | |
148 | - int nowWeek = DateUtils.getWeek(); | |
149 | - if (Week.contains(nowWeek + "") && nowWeek != 6 && nowWeek != 0) { //周末不告警 | |
150 | - logger.info((templateId + "_" + templateDto.getSchoolId() + "------" + beginTime + "_" + endTime)); | |
151 | - alarmMap.put(templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getTitle(), beginTime + "_" + endTime + "_" + type + "_" + templateDto.getId()); | |
152 | - } | |
153 | - } catch (Exception e) { | |
154 | - e.printStackTrace(); | |
155 | - } | |
156 | - } | |
157 | - } | |
158 | - } | |
159 | - | |
160 | - //告警推送 | |
161 | - private void alarm(Map.Entry<String, String> entry) { | |
162 | - String templateId = entry.getKey().split("_")[0]; | |
163 | - String schoolId = entry.getKey().split("_")[1]; | |
164 | - String id = entry.getValue().split("_")[3]; | |
165 | - String type = entry.getValue().split("_")[2]; | |
166 | - | |
167 | - if (DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5) { | |
168 | - //可以相差40% | |
169 | - BigDecimal percent = getAlarmCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); | |
170 | - if (templateMap.get(templateId) != null) { | |
171 | - if (percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.4)) > 0 | |
172 | - || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.4)) > 0) { | |
173 | - alarmPush(Integer.valueOf(schoolId)); | |
174 | - } | |
175 | - } | |
176 | - templateMap.put(templateId, percent); | |
177 | - } else { | |
178 | - //相差30% | |
179 | - BigDecimal percent = getAlarmCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); | |
180 | - if (templateMap.get(templateId) != null) { | |
181 | - if (percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.3)) > 0 | |
182 | - || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) { | |
183 | - alarmPush(Integer.valueOf(schoolId)); | |
184 | - } | |
185 | - } | |
186 | - templateMap.put(templateId, percent); | |
187 | - } | |
188 | - } | |
189 | - | |
190 | - private void insertIOT(Map.Entry<String, String> entry) { | |
191 | - String templateId = entry.getKey().split("_")[0]; | |
192 | - String schoolId = entry.getKey().split("_")[1]; | |
193 | - String title = entry.getKey().split("_")[2]; | |
194 | - String id = entry.getValue().split("_")[3]; | |
195 | - String type = entry.getValue().split("_")[2]; | |
196 | - String beginTime = entry.getValue().split("_")[0]; | |
197 | - String endTime = entry.getValue().split("_")[1]; | |
198 | - | |
199 | - List<Integer> list = getIOTCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); | |
200 | - JSONObject object = new JSONObject(); | |
201 | - object.put("strTime", beginTime); | |
202 | - object.put("endTime", endTime); | |
203 | - object.put("inTime", DateUtils.date2String(new Date(), DateUtils.format1)); | |
204 | - object.put("noAttendanceCount", list.get(1)); | |
205 | - object.put("attendanceCount", list.get(0)); | |
206 | - object.put("leaveCount", list.get(2)); | |
207 | - object.put("templateName", title); | |
208 | - object.put("qianDaoIdId", id); | |
209 | - object.put("schoolId", schoolId); | |
210 | - object.put("templateId", templateId); | |
211 | - HttpClientUtils.httpPostJson(iotUrl + "/api/Association/addIntelligenceAttendance", object.toJSONString()); | |
212 | - } | |
213 | - | |
214 | - //初始化要推送的模板 | |
215 | - private void initMap() { | |
216 | - map = new HashMap<>(); | |
217 | - List<TemplateDto> list = scFeign.getAllTemplate(); | |
218 | - logger.info(("------需要推送的考勤模板------")); | |
219 | - for (TemplateDto templateDto : list) { | |
220 | - String config = templateDto.getConfig(); | |
221 | - String[] array = config.split("<Template"); | |
222 | - for (int i = 1; i < array.length; i++) { | |
223 | - try { | |
224 | - String msg = array[i]; | |
225 | - String beginTime = msg.substring(msg.indexOf("BeginTime") + 11, msg.indexOf("BeginTime") + 16); | |
226 | - String endTime = msg.substring(msg.indexOf("EndTime") + 9, msg.indexOf("EndTime") + 14); | |
227 | - String templateId = msg.substring(msg.indexOf("TemplateID") + 12, msg.indexOf("TemplateID") + 22); | |
228 | - String Week = msg.substring(msg.indexOf("Week") + 6, msg.indexOf("Week") + 19); | |
229 | - String type = msg.substring(msg.indexOf("Type") + 6, msg.indexOf("Type") + 8); | |
230 | - type = type.replace("\"", ""); | |
231 | - int nowWeek = DateUtils.getWeek(); | |
232 | - if (Week.contains(nowWeek + "")) { | |
233 | - logger.info((templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getType() + "------" + beginTime + "_" + endTime)); | |
234 | - map.put(templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getType(), beginTime + "_" + endTime + "_" + type + "_" + templateDto.getId()); | |
235 | - } | |
236 | - } catch (Exception e) { | |
237 | - e.printStackTrace(); | |
238 | - } | |
239 | - } | |
240 | - } | |
241 | - } | |
242 | - | |
243 | - //盯盯批量推送 | |
244 | - private void dingBatchPush(String templateId, int schoolId, String key) { | |
245 | - String[] times = key.split("_"); | |
246 | - AppDto appDto = scFeign.getApp(schoolId, 1); | |
247 | - if (Integer.valueOf(times[2]) < 7) { | |
248 | - //出入校 推班主任 | |
249 | - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
250 | - for (KqTeacherDto teacher : list) { | |
251 | - dingSchoolPush(templateId, teacher, key, appDto, 0); | |
252 | - } | |
253 | - } else { | |
254 | - //出入寝 推班主任 | |
255 | - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
256 | - for (KqTeacherDto teacher : list) { | |
257 | - dingSchoolPush(templateId, teacher, key, appDto, 1); | |
258 | - } | |
259 | - //推宿管 | |
260 | - List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); | |
261 | - for (KqTeacherDto teacher : chamberList) { | |
262 | - dingChamberPush(templateId, teacher, key, appDto); | |
263 | - } | |
264 | - } | |
265 | - } | |
266 | - | |
267 | - //企业号批量推送 | |
268 | - private void weChatBatchPush(String templateId, int schoolId, String key) { | |
269 | - String[] times = key.split("_"); | |
270 | - AppDto appDto = scFeign.getApp(schoolId, 0); | |
271 | - if (Integer.valueOf(times[2]) < 7) { | |
272 | - //出入校 推班主任 | |
273 | - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
274 | - for (KqTeacherDto teacher : list) { | |
275 | - weChatSchoolPush(templateId, teacher, key, appDto, 0); | |
276 | - } | |
277 | - } else { | |
278 | - //出入寝 推班主任 | |
279 | - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
280 | - for (KqTeacherDto teacher : list) { | |
281 | - weChatSchoolPush(templateId, teacher, key, appDto, 1); | |
282 | - } | |
283 | - //推宿管 | |
284 | - List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); | |
285 | - for (KqTeacherDto teacher : chamberList) { | |
286 | - weChatChamberPush(templateId, teacher, key, appDto); | |
287 | - } | |
288 | - } | |
289 | - } | |
290 | - | |
291 | - //盯盯推送班主任 | |
292 | - private void dingSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) { | |
293 | - String[] times = key.split("_"); | |
294 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
295 | - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 0); | |
296 | - if (StringUtils.isNotBlank(thirdOpenId)) { | |
297 | - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type); | |
298 | - if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
299 | - String message = ""; | |
300 | - for (CensusKqDto censusKqDto : censusKqDtos) { | |
301 | - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
302 | - } | |
303 | - DingSms dingSms = new DingSms(); | |
304 | - dingSms.setName(teacher.getName()); | |
305 | - dingSms.setTableName("DingSmsNew" + tableSuffix); | |
306 | - dingSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
307 | - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
308 | - "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
309 | - "整体数据:" + message); | |
310 | - String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
311 | - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
312 | - "&data=" + thirdOpenId + "&type=1&stype=4&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + | |
313 | - "&face=&sourcetype=16&soutype=3×tamp=" + DateUtils.getDate() + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
314 | - dingSms.setSchoolId(teacher.getSchoolId()); | |
315 | - dingSms.setDingUserId(thirdOpenId); | |
316 | - dingSms.setAgentId(appDto.getAgentId()); | |
317 | - dingSms.setWapUrl(wapUrl); | |
318 | - dingSms.setReceiveUserId(teacher.getUserId()); | |
319 | - dingSms.setTdType(TypeEnums.kaoqing.getType()); | |
320 | - this.insertDing(dingSms); | |
321 | - logger.info("盯盯推送班主任—————" + templateId + "--------" + teacher.getName()); | |
322 | - } | |
323 | - } | |
324 | - } | |
325 | - | |
326 | - //盯盯推送宿管 | |
327 | - private void dingChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) { | |
328 | - String[] times = key.split("_"); | |
329 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
330 | - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 0); | |
331 | - if (StringUtils.isNotBlank(thirdOpenId)) { | |
332 | - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1); | |
333 | - if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
334 | - String message = ""; | |
335 | - for (CensusKqDto censusKqDto : censusKqDtos) { | |
336 | - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
337 | - } | |
338 | - DingSms dingSms = new DingSms(); | |
339 | - dingSms.setName(teacher.getName()); | |
340 | - dingSms.setTableName("DingSmsNew" + tableSuffix); | |
341 | - dingSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
342 | - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
343 | - "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
344 | - "整体数据:" + message); | |
345 | - String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
346 | - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
347 | - "&pass=" + teacher.getPass() + "&type=4&soutype=3&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
348 | - dingSms.setSchoolId(teacher.getSchoolId()); | |
349 | - dingSms.setDingUserId(thirdOpenId); | |
350 | - dingSms.setAgentId(appDto.getAgentId()); | |
351 | - dingSms.setWapUrl(msgUrl); | |
352 | - dingSms.setReceiveUserId(teacher.getUserId()); | |
353 | - dingSms.setTdType(TypeEnums.kaoqing.getType()); | |
354 | - this.insertDing(dingSms); | |
355 | - logger.info("盯盯推送宿管—————" + templateId + "--------" + teacher.getName()); | |
356 | - } | |
357 | - } | |
358 | - } | |
359 | - | |
360 | - //企业号推送班主任 | |
361 | - private void weChatSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) { | |
362 | - String[] times = key.split("_"); | |
363 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
364 | - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1); | |
365 | - if (StringUtils.isNotBlank(thirdOpenId)) { | |
366 | - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type); | |
367 | - if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
368 | - String message = ""; | |
369 | - for (CensusKqDto censusKqDto : censusKqDtos) { | |
370 | - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
371 | - } | |
372 | - WeChatSms weChatSms = new WeChatSms(); | |
373 | - weChatSms.setTableName("qyhSmsNew" + tableSuffix); | |
374 | - weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
375 | - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
376 | - "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
377 | - "整体数据:" + message); | |
378 | - weChatSms.setSchoolId(teacher.getSchoolId()); | |
379 | - weChatSms.setName(teacher.getName()); | |
380 | - weChatSms.setQiYeHaoUserId(thirdOpenId); | |
381 | - weChatSms.setReceiveUserId(teacher.getUserId()); | |
382 | - weChatSms.setAppId(appDto.getAgentId()); | |
383 | - weChatSms.setSecret(appDto.getAgentSecret()); | |
384 | - String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
385 | - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
386 | - "&data=" + thirdOpenId + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + | |
387 | - "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2×tamp=" + DateUtils.getDate() + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1) + "&"; | |
388 | - weChatSms.setMsgUrl(msgUrl); | |
389 | - weChatSms.setTdType(TypeEnums.kaoqing.getType()); | |
390 | - this.insertQYH(weChatSms); | |
391 | - logger.info("企业号推送班主任—————" + templateId + "--------" + teacher.getName()); | |
392 | - } | |
393 | - } | |
394 | - } | |
395 | - | |
396 | - //企业号推送宿管 | |
397 | - private void weChatChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) { | |
398 | - String[] times = key.split("_"); | |
399 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
400 | - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1); | |
401 | - if (StringUtils.isNotBlank(thirdOpenId)) { | |
402 | - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1); | |
403 | - if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
404 | - String message = ""; | |
405 | - for (CensusKqDto censusKqDto : censusKqDtos) { | |
406 | - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
407 | - } | |
408 | - WeChatSms weChatSms = new WeChatSms(); | |
409 | - weChatSms.setTableName("qyhSmsNew" + tableSuffix); | |
410 | - weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
411 | - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
412 | - "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
413 | - "整体数据:" + message); | |
414 | - weChatSms.setSchoolId(teacher.getSchoolId()); | |
415 | - weChatSms.setName(teacher.getName()); | |
416 | - weChatSms.setQiYeHaoUserId(thirdOpenId); | |
417 | - weChatSms.setReceiveUserId(teacher.getUserId()); | |
418 | - weChatSms.setAppId(appDto.getAgentId()); | |
419 | - weChatSms.setSecret(appDto.getAgentSecret()); | |
420 | - String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
421 | - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
422 | - "&pass=" + teacher.getPass() + "&type=4&soutype=2&time=" + DateUtils.date2String(new Date(), DateUtils.format1) + "&"; | |
423 | - weChatSms.setMsgUrl(msgUrl); | |
424 | - weChatSms.setTdType(TypeEnums.kaoqing.getType()); | |
425 | - this.insertQYH(weChatSms); | |
426 | - logger.info("企业号推送宿管—————" + templateId + "--------" + teacher.getName()); | |
427 | - } | |
428 | - } | |
429 | - } | |
430 | - | |
431 | - //type 0 出入校 1 出入寝 | |
432 | - private List<CensusKqDto> getCensus(int id, String templateId, int schoolId, String userId, int type) { | |
433 | - List<CensusKqDto> list = new ArrayList<>(); | |
434 | - String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetailNew?schoolId=" + schoolId + | |
435 | - "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&userId=" + userId + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
436 | - JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
437 | - try { | |
438 | - JSONArray data = (JSONArray) jsonObject.get("data"); | |
439 | - for (int i = 0; i < data.size(); i++) { | |
440 | - CensusKqDto censusKqDto = new CensusKqDto(); | |
441 | - JSONObject object = data.getJSONObject(i); | |
442 | - censusKqDto.setLeaveCount((Integer) object.get("leaveCount")); | |
443 | - censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount")); | |
444 | - censusKqDto.setTargetName((String) object.get("name")); | |
445 | - list.add(censusKqDto); | |
446 | - } | |
447 | - } catch (Exception e) { | |
448 | - | |
449 | - } | |
450 | - return list; | |
451 | - } | |
452 | - | |
453 | - private BigDecimal getAlarmCensus(int id, String templateId, int schoolId, int type) { | |
454 | - int allNumber = 0, attendNumber = 0; | |
455 | - List<Integer> list = scFeign.selectClassBySchoolId(schoolId); | |
456 | - for (Integer classId : list) { | |
457 | - String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId=" + classId + | |
458 | - "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
459 | - JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
460 | - try { | |
461 | - JSONObject data = (JSONObject) jsonObject.get("data"); | |
462 | - attendNumber = attendNumber + (Integer) data.get("stuAttendCount"); | |
463 | - allNumber = allNumber + (Integer) data.get("stuCount"); | |
464 | - } catch (Exception e) { | |
465 | - e.printStackTrace(); | |
466 | - } | |
467 | - } | |
468 | - if (allNumber != 0) { | |
469 | - BigDecimal pecrent = new BigDecimal(attendNumber).divide(new BigDecimal(allNumber), 10, BigDecimal.ROUND_HALF_DOWN); | |
470 | - return pecrent; | |
471 | - } else { | |
472 | - return BigDecimal.ZERO; | |
473 | - } | |
474 | - | |
475 | - } | |
476 | - | |
477 | - /** | |
478 | - * @param id | |
479 | - * @param templateId | |
480 | - * @param schoolId | |
481 | - * @param type | |
482 | - * @return list(0) 出勤 list(1) 未出勤 List(2) 请假 | |
483 | - */ | |
484 | - private List<Integer> getIOTCensus(int id, String templateId, int schoolId, int type) { | |
485 | - List<Integer> result = new ArrayList<>(); | |
486 | - int attend = 0, unattend = 0, leave = 0; | |
487 | - List<Integer> list = scFeign.selectClassBySchoolId(schoolId); | |
488 | - for (Integer classId : list) { | |
489 | - String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId=" + classId + | |
490 | - "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
491 | - JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
492 | - try { | |
493 | - JSONObject data = (JSONObject) jsonObject.get("data"); | |
494 | - attend = attend + (Integer) data.get("stuAttendCount"); | |
495 | - unattend = unattend + (Integer) data.get("noAttendCount"); | |
496 | - leave = leave + (Integer) data.get("leaveCount"); | |
497 | - } catch (Exception e) { | |
498 | - e.printStackTrace(); | |
499 | - } | |
500 | - } | |
501 | - result.add(attend); | |
502 | - result.add(unattend); | |
503 | - result.add(leave); | |
504 | - return result; | |
505 | - } | |
506 | - | |
507 | - | |
508 | - private void insertDing(DingSms dingSms) { | |
509 | - try { | |
510 | - smsService.insertDing(dingSms); | |
511 | - } catch (Exception e) { | |
512 | - logger.info(e.toString()); | |
513 | - } | |
514 | - } | |
515 | - | |
516 | - private void insertQYH(WeChatSms weChatSms) { | |
517 | - try { | |
518 | - smsService.insertWeChat(weChatSms); | |
519 | - } catch (Exception e) { | |
520 | - logger.info(e.toString()); | |
521 | - } | |
522 | - } | |
523 | - | |
524 | - private void alarmPush(int schoolId) { | |
525 | - String msg = "【考勤异动】"; | |
526 | - try { | |
527 | - SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
528 | - msg += schoolDto.getSchoolName() + "考勤有异动,请关注!"; | |
529 | - sendMessage(schoolDto.getSchoolId(), opexList.get(0), msg); | |
530 | - sendMessage(schoolDto.getSchoolId(), opexList.get(1), msg); | |
531 | - sendMessage(schoolDto.getSchoolId(), integration, msg); | |
532 | - String managerPhone = managerService.selectManagerById(schoolDto.getManagerUserId()); | |
533 | - if (StringUtils.isNotBlank(managerPhone)) { | |
534 | - sendMessage(schoolDto.getSchoolId(), managerPhone, msg); | |
535 | - } | |
536 | - } catch (Exception e) { | |
537 | - e.printStackTrace(); | |
538 | - } | |
539 | - | |
540 | - } | |
541 | - | |
542 | - private void sendMessage(int schoolId, String mobile, String msg) { | |
543 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
544 | - ShortMsg shortMsg = new ShortMsg(); | |
545 | - shortMsg.setTableName("smsNew" + tableSuffix); | |
546 | - shortMsg.setSchoolId(schoolId); | |
547 | - shortMsg.setMobile(mobile); | |
548 | - shortMsg.setMsg(msg); | |
549 | - smsService.insertSMS(shortMsg); | |
550 | - } | |
551 | -} | |
1 | +//package com.sincere.quartz.job; | |
2 | +// | |
3 | +//import com.alibaba.fastjson.JSONArray; | |
4 | +//import com.alibaba.fastjson.JSONObject; | |
5 | +//import com.sincere.common.dto.smartCampus.*; | |
6 | +//import com.sincere.common.enums.PushTypeEnums; | |
7 | +//import com.sincere.common.util.DateUtils; | |
8 | +//import com.sincere.common.util.HttpClientUtils; | |
9 | +//import com.sincere.quartz.enums.KqTypeEnums; | |
10 | +//import com.sincere.quartz.enums.TypeEnums; | |
11 | +//import com.sincere.quartz.feign.ScFeign; | |
12 | +//import com.sincere.quartz.model.DingSms; | |
13 | +//import com.sincere.quartz.model.ShortMsg; | |
14 | +//import com.sincere.quartz.model.WeChatSms; | |
15 | +//import com.sincere.quartz.service.ManagerService; | |
16 | +//import com.sincere.quartz.service.SmsService; | |
17 | +//import org.apache.commons.lang3.StringUtils; | |
18 | +//import org.slf4j.Logger; | |
19 | +//import org.slf4j.LoggerFactory; | |
20 | +//import org.springframework.beans.factory.annotation.Autowired; | |
21 | +//import org.springframework.scheduling.annotation.Scheduled; | |
22 | +//import org.springframework.stereotype.Service; | |
23 | +// | |
24 | +//import java.math.BigDecimal; | |
25 | +//import java.util.*; | |
26 | +// | |
27 | +///** | |
28 | +// * 考勤任务推送调用 | |
29 | +// * 主要推送盯盯以及企业号 | |
30 | +// * | |
31 | +// * @author chen | |
32 | +// * @version 1.0 | |
33 | +// * @date 2019/11/27 0027 17:05 | |
34 | +// */ | |
35 | +//@Service | |
36 | +//public class KQJob { | |
37 | +// | |
38 | +// private Logger logger = LoggerFactory.getLogger(KQJob.class); | |
39 | +// | |
40 | +// @Autowired | |
41 | +// ScFeign scFeign; | |
42 | +// | |
43 | +// @Autowired | |
44 | +// SmsService smsService; | |
45 | +// | |
46 | +// @Autowired | |
47 | +// ManagerService managerService; | |
48 | +// | |
49 | +// private static String iotUrl = "http://60.190.202.57:8035"; | |
50 | +// | |
51 | +// private static String date; | |
52 | +// private static Map<String, String> map = new HashMap<>(); //学校 考勤推送map | |
53 | +// | |
54 | +// private static String alarmDate; | |
55 | +// private static Map<String, String> alarmMap = new HashMap<>(); //考勤告警推送map | |
56 | +// private static Map<String, BigDecimal> templateMap = new HashMap<>(); // 考勤比例 | |
57 | +// | |
58 | +// private static List<String> opexList; | |
59 | +// private static String integration; | |
60 | +// | |
61 | +// static { | |
62 | +// opexList = new ArrayList<>(); | |
63 | +// opexList.add("15857566147"); //王汉栋 | |
64 | +// opexList.add("13858485977"); //王楠彬 | |
65 | +// | |
66 | +// integration = "18767117554"; //林炜 | |
67 | +// } | |
68 | +// | |
69 | +// @Scheduled(cron = "0 0-59 * * * ? ") | |
70 | +// public void kaoQing() { | |
71 | +// String now = DateUtils.date2String(new Date(), DateUtils.format1); | |
72 | +// if (StringUtils.isBlank(date)) { | |
73 | +// initMap(); | |
74 | +// date = now; | |
75 | +// } | |
76 | +// if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(date)) { | |
77 | +// initMap(); | |
78 | +// date = DateUtils.date2String(new Date(), DateUtils.format1); | |
79 | +// } | |
80 | +// //开始过滤数据 推送 | |
81 | +// List<String> keyList = new ArrayList<>(); | |
82 | +// for (Map.Entry<String, String> entity : map.entrySet()) { | |
83 | +// String endTime = entity.getValue().split("_")[1]; | |
84 | +// if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2 | |
85 | +// && DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") < 5) { | |
86 | +// String key = entity.getKey(); | |
87 | +// String[] messageArray = key.split("_"); | |
88 | +// if (messageArray[2].contains(PushTypeEnums.QIYEHAO.getType() + "")) { | |
89 | +// logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]); | |
90 | +// weChatBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue()); | |
91 | +// } | |
92 | +// if (messageArray[2].contains(PushTypeEnums.DING.getType() + "")) { | |
93 | +// logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1])); | |
94 | +// dingBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue()); | |
95 | +// } | |
96 | +// keyList.add(key); | |
97 | +// } | |
98 | +// } | |
99 | +// for (String key : keyList) { | |
100 | +// map.remove(key); | |
101 | +// } | |
102 | +// } | |
103 | +// | |
104 | +// @Scheduled(cron = "0 0-59 * * * ? ") | |
105 | +// public void alarmKaoQing() { | |
106 | +// String now = DateUtils.date2String(new Date(), DateUtils.format1); | |
107 | +// if (StringUtils.isBlank(alarmDate)) { | |
108 | +// initAlarmMap(); | |
109 | +// alarmDate = now; | |
110 | +// } | |
111 | +// if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(alarmDate)) { | |
112 | +// initAlarmMap(); | |
113 | +// alarmDate = DateUtils.date2String(new Date(), DateUtils.format1); | |
114 | +// } | |
115 | +// //开始过滤数据 推送 | |
116 | +// List<String> keyList = new ArrayList<>(); | |
117 | +// for (Map.Entry<String, String> entity : alarmMap.entrySet()) { | |
118 | +// String endTime = entity.getValue().split("_")[1]; | |
119 | +// if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2 | |
120 | +// ) { | |
121 | +// String key = entity.getKey(); | |
122 | +// keyList.add(key); | |
123 | +// //alarm(entity); //告警 | |
124 | +// //insertIOT(entity); //iot | |
125 | +// } | |
126 | +// } | |
127 | +// for (String key : keyList) { | |
128 | +// map.remove(key); | |
129 | +// } | |
130 | +// } | |
131 | +// | |
132 | +// private void initAlarmMap() { | |
133 | +// alarmMap = new HashMap<>(); | |
134 | +// List<TemplateDto> list = scFeign.getAllTemplateAlarm(); | |
135 | +// logger.info(("------考勤告警模板------")); | |
136 | +// for (TemplateDto templateDto : list) { | |
137 | +// String config = templateDto.getConfig(); | |
138 | +// String[] array = config.split("<Template"); | |
139 | +// for (int i = 1; i < array.length; i++) { | |
140 | +// try { | |
141 | +// String msg = array[i]; | |
142 | +// String beginTime = msg.substring(msg.indexOf("BeginTime") + 11, msg.indexOf("BeginTime") + 16); | |
143 | +// String endTime = msg.substring(msg.indexOf("EndTime") + 9, msg.indexOf("EndTime") + 14); | |
144 | +// String templateId = msg.substring(msg.indexOf("TemplateID") + 12, msg.indexOf("TemplateID") + 22); | |
145 | +// String Week = msg.substring(msg.indexOf("Week") + 6, msg.indexOf("Week") + 19); | |
146 | +// String type = msg.substring(msg.indexOf("Type") + 6, msg.indexOf("Type") + 8); | |
147 | +// type = type.replace("\"", ""); | |
148 | +// int nowWeek = DateUtils.getWeek(); | |
149 | +// if (Week.contains(nowWeek + "") && nowWeek != 6 && nowWeek != 0) { //周末不告警 | |
150 | +// logger.info((templateId + "_" + templateDto.getSchoolId() + "------" + beginTime + "_" + endTime)); | |
151 | +// alarmMap.put(templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getTitle(), beginTime + "_" + endTime + "_" + type + "_" + templateDto.getId()); | |
152 | +// } | |
153 | +// } catch (Exception e) { | |
154 | +// e.printStackTrace(); | |
155 | +// } | |
156 | +// } | |
157 | +// } | |
158 | +// } | |
159 | +// | |
160 | +// //告警推送 | |
161 | +// private void alarm(Map.Entry<String, String> entry) { | |
162 | +// String templateId = entry.getKey().split("_")[0]; | |
163 | +// String schoolId = entry.getKey().split("_")[1]; | |
164 | +// String id = entry.getValue().split("_")[3]; | |
165 | +// String type = entry.getValue().split("_")[2]; | |
166 | +// | |
167 | +// if (DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5) { | |
168 | +// //可以相差40% | |
169 | +// BigDecimal percent = getAlarmCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); | |
170 | +// if (templateMap.get(templateId) != null) { | |
171 | +// if (percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.4)) > 0 | |
172 | +// || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.4)) > 0) { | |
173 | +// alarmPush(Integer.valueOf(schoolId)); | |
174 | +// } | |
175 | +// } | |
176 | +// templateMap.put(templateId, percent); | |
177 | +// } else { | |
178 | +// //相差30% | |
179 | +// BigDecimal percent = getAlarmCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); | |
180 | +// if (templateMap.get(templateId) != null) { | |
181 | +// if (percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.3)) > 0 | |
182 | +// || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) { | |
183 | +// alarmPush(Integer.valueOf(schoolId)); | |
184 | +// } | |
185 | +// } | |
186 | +// templateMap.put(templateId, percent); | |
187 | +// } | |
188 | +// } | |
189 | +// | |
190 | +// private void insertIOT(Map.Entry<String, String> entry) { | |
191 | +// String templateId = entry.getKey().split("_")[0]; | |
192 | +// String schoolId = entry.getKey().split("_")[1]; | |
193 | +// String title = entry.getKey().split("_")[2]; | |
194 | +// String id = entry.getValue().split("_")[3]; | |
195 | +// String type = entry.getValue().split("_")[2]; | |
196 | +// String beginTime = entry.getValue().split("_")[0]; | |
197 | +// String endTime = entry.getValue().split("_")[1]; | |
198 | +// | |
199 | +// List<Integer> list = getIOTCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); | |
200 | +// JSONObject object = new JSONObject(); | |
201 | +// object.put("strTime", beginTime); | |
202 | +// object.put("endTime", endTime); | |
203 | +// object.put("inTime", DateUtils.date2String(new Date(), DateUtils.format1)); | |
204 | +// object.put("noAttendanceCount", list.get(1)); | |
205 | +// object.put("attendanceCount", list.get(0)); | |
206 | +// object.put("leaveCount", list.get(2)); | |
207 | +// object.put("templateName", title); | |
208 | +// object.put("qianDaoIdId", id); | |
209 | +// object.put("schoolId", schoolId); | |
210 | +// object.put("templateId", templateId); | |
211 | +// HttpClientUtils.httpPostJson(iotUrl + "/api/Association/addIntelligenceAttendance", object.toJSONString()); | |
212 | +// } | |
213 | +// | |
214 | +// //初始化要推送的模板 | |
215 | +// private void initMap() { | |
216 | +// map = new HashMap<>(); | |
217 | +// List<TemplateDto> list = scFeign.getAllTemplate(); | |
218 | +// logger.info(("------需要推送的考勤模板------")); | |
219 | +// for (TemplateDto templateDto : list) { | |
220 | +// String config = templateDto.getConfig(); | |
221 | +// String[] array = config.split("<Template"); | |
222 | +// for (int i = 1; i < array.length; i++) { | |
223 | +// try { | |
224 | +// String msg = array[i]; | |
225 | +// String beginTime = msg.substring(msg.indexOf("BeginTime") + 11, msg.indexOf("BeginTime") + 16); | |
226 | +// String endTime = msg.substring(msg.indexOf("EndTime") + 9, msg.indexOf("EndTime") + 14); | |
227 | +// String templateId = msg.substring(msg.indexOf("TemplateID") + 12, msg.indexOf("TemplateID") + 22); | |
228 | +// String Week = msg.substring(msg.indexOf("Week") + 6, msg.indexOf("Week") + 19); | |
229 | +// String type = msg.substring(msg.indexOf("Type") + 6, msg.indexOf("Type") + 8); | |
230 | +// type = type.replace("\"", ""); | |
231 | +// int nowWeek = DateUtils.getWeek(); | |
232 | +// if (Week.contains(nowWeek + "")) { | |
233 | +// logger.info((templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getType() + "------" + beginTime + "_" + endTime)); | |
234 | +// map.put(templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getType(), beginTime + "_" + endTime + "_" + type + "_" + templateDto.getId()); | |
235 | +// } | |
236 | +// } catch (Exception e) { | |
237 | +// e.printStackTrace(); | |
238 | +// } | |
239 | +// } | |
240 | +// } | |
241 | +// } | |
242 | +// | |
243 | +// //盯盯批量推送 | |
244 | +// private void dingBatchPush(String templateId, int schoolId, String key) { | |
245 | +// String[] times = key.split("_"); | |
246 | +// AppDto appDto = scFeign.getApp(schoolId, 1); | |
247 | +// if (Integer.valueOf(times[2]) < 7) { | |
248 | +// //出入校 推班主任 | |
249 | +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
250 | +// for (KqTeacherDto teacher : list) { | |
251 | +// dingSchoolPush(templateId, teacher, key, appDto, 0); | |
252 | +// } | |
253 | +// } else { | |
254 | +// //出入寝 推班主任 | |
255 | +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
256 | +// for (KqTeacherDto teacher : list) { | |
257 | +// dingSchoolPush(templateId, teacher, key, appDto, 1); | |
258 | +// } | |
259 | +// //推宿管 | |
260 | +// List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); | |
261 | +// for (KqTeacherDto teacher : chamberList) { | |
262 | +// dingChamberPush(templateId, teacher, key, appDto); | |
263 | +// } | |
264 | +// } | |
265 | +// } | |
266 | +// | |
267 | +// //企业号批量推送 | |
268 | +// private void weChatBatchPush(String templateId, int schoolId, String key) { | |
269 | +// String[] times = key.split("_"); | |
270 | +// AppDto appDto = scFeign.getApp(schoolId, 0); | |
271 | +// if (Integer.valueOf(times[2]) < 7) { | |
272 | +// //出入校 推班主任 | |
273 | +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
274 | +// for (KqTeacherDto teacher : list) { | |
275 | +// weChatSchoolPush(templateId, teacher, key, appDto, 0); | |
276 | +// } | |
277 | +// } else { | |
278 | +// //出入寝 推班主任 | |
279 | +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); | |
280 | +// for (KqTeacherDto teacher : list) { | |
281 | +// weChatSchoolPush(templateId, teacher, key, appDto, 1); | |
282 | +// } | |
283 | +// //推宿管 | |
284 | +// List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); | |
285 | +// for (KqTeacherDto teacher : chamberList) { | |
286 | +// weChatChamberPush(templateId, teacher, key, appDto); | |
287 | +// } | |
288 | +// } | |
289 | +// } | |
290 | +// | |
291 | +// //盯盯推送班主任 | |
292 | +// private void dingSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) { | |
293 | +// String[] times = key.split("_"); | |
294 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
295 | +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 0); | |
296 | +// if (StringUtils.isNotBlank(thirdOpenId)) { | |
297 | +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type); | |
298 | +// if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
299 | +// String message = ""; | |
300 | +// for (CensusKqDto censusKqDto : censusKqDtos) { | |
301 | +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
302 | +// } | |
303 | +// DingSms dingSms = new DingSms(); | |
304 | +// dingSms.setName(teacher.getName()); | |
305 | +// dingSms.setTableName("DingSmsNew" + tableSuffix); | |
306 | +// dingSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
307 | +// "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
308 | +// "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
309 | +// "整体数据:" + message); | |
310 | +// String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
311 | +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
312 | +// "&data=" + thirdOpenId + "&type=1&stype=4&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + | |
313 | +// "&face=&sourcetype=16&soutype=3×tamp=" + DateUtils.getDate() + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
314 | +// dingSms.setSchoolId(teacher.getSchoolId()); | |
315 | +// dingSms.setDingUserId(thirdOpenId); | |
316 | +// dingSms.setAgentId(appDto.getAgentId()); | |
317 | +// dingSms.setWapUrl(wapUrl); | |
318 | +// dingSms.setReceiveUserId(teacher.getUserId()); | |
319 | +// dingSms.setTdType(TypeEnums.kaoqing.getType()); | |
320 | +// this.insertDing(dingSms); | |
321 | +// logger.info("盯盯推送班主任—————" + templateId + "--------" + teacher.getName()); | |
322 | +// } | |
323 | +// } | |
324 | +// } | |
325 | +// | |
326 | +// //盯盯推送宿管 | |
327 | +// private void dingChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) { | |
328 | +// String[] times = key.split("_"); | |
329 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
330 | +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 0); | |
331 | +// if (StringUtils.isNotBlank(thirdOpenId)) { | |
332 | +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1); | |
333 | +// if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
334 | +// String message = ""; | |
335 | +// for (CensusKqDto censusKqDto : censusKqDtos) { | |
336 | +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
337 | +// } | |
338 | +// DingSms dingSms = new DingSms(); | |
339 | +// dingSms.setName(teacher.getName()); | |
340 | +// dingSms.setTableName("DingSmsNew" + tableSuffix); | |
341 | +// dingSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
342 | +// "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
343 | +// "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
344 | +// "整体数据:" + message); | |
345 | +// String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
346 | +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
347 | +// "&pass=" + teacher.getPass() + "&type=4&soutype=3&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
348 | +// dingSms.setSchoolId(teacher.getSchoolId()); | |
349 | +// dingSms.setDingUserId(thirdOpenId); | |
350 | +// dingSms.setAgentId(appDto.getAgentId()); | |
351 | +// dingSms.setWapUrl(msgUrl); | |
352 | +// dingSms.setReceiveUserId(teacher.getUserId()); | |
353 | +// dingSms.setTdType(TypeEnums.kaoqing.getType()); | |
354 | +// this.insertDing(dingSms); | |
355 | +// logger.info("盯盯推送宿管—————" + templateId + "--------" + teacher.getName()); | |
356 | +// } | |
357 | +// } | |
358 | +// } | |
359 | +// | |
360 | +// //企业号推送班主任 | |
361 | +// private void weChatSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) { | |
362 | +// String[] times = key.split("_"); | |
363 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
364 | +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1); | |
365 | +// if (StringUtils.isNotBlank(thirdOpenId)) { | |
366 | +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type); | |
367 | +// if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
368 | +// String message = ""; | |
369 | +// for (CensusKqDto censusKqDto : censusKqDtos) { | |
370 | +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
371 | +// } | |
372 | +// WeChatSms weChatSms = new WeChatSms(); | |
373 | +// weChatSms.setTableName("qyhSmsNew" + tableSuffix); | |
374 | +// weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
375 | +// "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
376 | +// "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
377 | +// "整体数据:" + message); | |
378 | +// weChatSms.setSchoolId(teacher.getSchoolId()); | |
379 | +// weChatSms.setName(teacher.getName()); | |
380 | +// weChatSms.setQiYeHaoUserId(thirdOpenId); | |
381 | +// weChatSms.setReceiveUserId(teacher.getUserId()); | |
382 | +// weChatSms.setAppId(appDto.getAgentId()); | |
383 | +// weChatSms.setSecret(appDto.getAgentSecret()); | |
384 | +// String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
385 | +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
386 | +// "&data=" + thirdOpenId + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + | |
387 | +// "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2×tamp=" + DateUtils.getDate() + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1) + "&"; | |
388 | +// weChatSms.setMsgUrl(msgUrl); | |
389 | +// weChatSms.setTdType(TypeEnums.kaoqing.getType()); | |
390 | +// this.insertQYH(weChatSms); | |
391 | +// logger.info("企业号推送班主任—————" + templateId + "--------" + teacher.getName()); | |
392 | +// } | |
393 | +// } | |
394 | +// } | |
395 | +// | |
396 | +// //企业号推送宿管 | |
397 | +// private void weChatChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) { | |
398 | +// String[] times = key.split("_"); | |
399 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
400 | +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1); | |
401 | +// if (StringUtils.isNotBlank(thirdOpenId)) { | |
402 | +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1); | |
403 | +// if (censusKqDtos != null && censusKqDtos.size() > 0) { | |
404 | +// String message = ""; | |
405 | +// for (CensusKqDto censusKqDto : censusKqDtos) { | |
406 | +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; | |
407 | +// } | |
408 | +// WeChatSms weChatSms = new WeChatSms(); | |
409 | +// weChatSms.setTableName("qyhSmsNew" + tableSuffix); | |
410 | +// weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " + | |
411 | +// "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " + | |
412 | +// "签到时间:" + times[0] + "-" + times[1] + " \n - " + | |
413 | +// "整体数据:" + message); | |
414 | +// weChatSms.setSchoolId(teacher.getSchoolId()); | |
415 | +// weChatSms.setName(teacher.getName()); | |
416 | +// weChatSms.setQiYeHaoUserId(thirdOpenId); | |
417 | +// weChatSms.setReceiveUserId(teacher.getUserId()); | |
418 | +// weChatSms.setAppId(appDto.getAgentId()); | |
419 | +// weChatSms.setSecret(appDto.getAgentSecret()); | |
420 | +// String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + | |
421 | +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + | |
422 | +// "&pass=" + teacher.getPass() + "&type=4&soutype=2&time=" + DateUtils.date2String(new Date(), DateUtils.format1) + "&"; | |
423 | +// weChatSms.setMsgUrl(msgUrl); | |
424 | +// weChatSms.setTdType(TypeEnums.kaoqing.getType()); | |
425 | +// this.insertQYH(weChatSms); | |
426 | +// logger.info("企业号推送宿管—————" + templateId + "--------" + teacher.getName()); | |
427 | +// } | |
428 | +// } | |
429 | +// } | |
430 | +// | |
431 | +// //type 0 出入校 1 出入寝 | |
432 | +// private List<CensusKqDto> getCensus(int id, String templateId, int schoolId, String userId, int type) { | |
433 | +// List<CensusKqDto> list = new ArrayList<>(); | |
434 | +// String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetailNew?schoolId=" + schoolId + | |
435 | +// "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&userId=" + userId + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
436 | +// JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
437 | +// try { | |
438 | +// JSONArray data = (JSONArray) jsonObject.get("data"); | |
439 | +// for (int i = 0; i < data.size(); i++) { | |
440 | +// CensusKqDto censusKqDto = new CensusKqDto(); | |
441 | +// JSONObject object = data.getJSONObject(i); | |
442 | +// censusKqDto.setLeaveCount((Integer) object.get("leaveCount")); | |
443 | +// censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount")); | |
444 | +// censusKqDto.setTargetName((String) object.get("name")); | |
445 | +// list.add(censusKqDto); | |
446 | +// } | |
447 | +// } catch (Exception e) { | |
448 | +// | |
449 | +// } | |
450 | +// return list; | |
451 | +// } | |
452 | +// | |
453 | +// private BigDecimal getAlarmCensus(int id, String templateId, int schoolId, int type) { | |
454 | +// int allNumber = 0, attendNumber = 0; | |
455 | +// List<Integer> list = scFeign.selectClassBySchoolId(schoolId); | |
456 | +// for (Integer classId : list) { | |
457 | +// String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId=" + classId + | |
458 | +// "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
459 | +// JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
460 | +// try { | |
461 | +// JSONObject data = (JSONObject) jsonObject.get("data"); | |
462 | +// attendNumber = attendNumber + (Integer) data.get("stuAttendCount"); | |
463 | +// allNumber = allNumber + (Integer) data.get("stuCount"); | |
464 | +// } catch (Exception e) { | |
465 | +// e.printStackTrace(); | |
466 | +// } | |
467 | +// } | |
468 | +// if (allNumber != 0) { | |
469 | +// BigDecimal pecrent = new BigDecimal(attendNumber).divide(new BigDecimal(allNumber), 10, BigDecimal.ROUND_HALF_DOWN); | |
470 | +// return pecrent; | |
471 | +// } else { | |
472 | +// return BigDecimal.ZERO; | |
473 | +// } | |
474 | +// | |
475 | +// } | |
476 | +// | |
477 | +// /** | |
478 | +// * @param id | |
479 | +// * @param templateId | |
480 | +// * @param schoolId | |
481 | +// * @param type | |
482 | +// * @return list(0) 出勤 list(1) 未出勤 List(2) 请假 | |
483 | +// */ | |
484 | +// private List<Integer> getIOTCensus(int id, String templateId, int schoolId, int type) { | |
485 | +// List<Integer> result = new ArrayList<>(); | |
486 | +// int attend = 0, unattend = 0, leave = 0; | |
487 | +// List<Integer> list = scFeign.selectClassBySchoolId(schoolId); | |
488 | +// for (Integer classId : list) { | |
489 | +// String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId=" + classId + | |
490 | +// "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1); | |
491 | +// JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
492 | +// try { | |
493 | +// JSONObject data = (JSONObject) jsonObject.get("data"); | |
494 | +// attend = attend + (Integer) data.get("stuAttendCount"); | |
495 | +// unattend = unattend + (Integer) data.get("noAttendCount"); | |
496 | +// leave = leave + (Integer) data.get("leaveCount"); | |
497 | +// } catch (Exception e) { | |
498 | +// e.printStackTrace(); | |
499 | +// } | |
500 | +// } | |
501 | +// result.add(attend); | |
502 | +// result.add(unattend); | |
503 | +// result.add(leave); | |
504 | +// return result; | |
505 | +// } | |
506 | +// | |
507 | +// | |
508 | +// private void insertDing(DingSms dingSms) { | |
509 | +// try { | |
510 | +// smsService.insertDing(dingSms); | |
511 | +// } catch (Exception e) { | |
512 | +// logger.info(e.toString()); | |
513 | +// } | |
514 | +// } | |
515 | +// | |
516 | +// private void insertQYH(WeChatSms weChatSms) { | |
517 | +// try { | |
518 | +// smsService.insertWeChat(weChatSms); | |
519 | +// } catch (Exception e) { | |
520 | +// logger.info(e.toString()); | |
521 | +// } | |
522 | +// } | |
523 | +// | |
524 | +// private void alarmPush(int schoolId) { | |
525 | +// String msg = "【考勤异动】"; | |
526 | +// try { | |
527 | +// SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
528 | +// msg += schoolDto.getSchoolName() + "考勤有异动,请关注!"; | |
529 | +// sendMessage(schoolDto.getSchoolId(), opexList.get(0), msg); | |
530 | +// sendMessage(schoolDto.getSchoolId(), opexList.get(1), msg); | |
531 | +// sendMessage(schoolDto.getSchoolId(), integration, msg); | |
532 | +// String managerPhone = managerService.selectManagerById(schoolDto.getManagerUserId()); | |
533 | +// if (StringUtils.isNotBlank(managerPhone)) { | |
534 | +// sendMessage(schoolDto.getSchoolId(), managerPhone, msg); | |
535 | +// } | |
536 | +// } catch (Exception e) { | |
537 | +// e.printStackTrace(); | |
538 | +// } | |
539 | +// | |
540 | +// } | |
541 | +// | |
542 | +// private void sendMessage(int schoolId, String mobile, String msg) { | |
543 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
544 | +// ShortMsg shortMsg = new ShortMsg(); | |
545 | +// shortMsg.setTableName("smsNew" + tableSuffix); | |
546 | +// shortMsg.setSchoolId(schoolId); | |
547 | +// shortMsg.setMobile(mobile); | |
548 | +// shortMsg.setMsg(msg); | |
549 | +// smsService.insertSMS(shortMsg); | |
550 | +// } | |
551 | +//} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
1 | -package com.sincere.quartz.job; | |
2 | - | |
3 | -import com.sincere.quartz.third.yixueyun.YXYReadService; | |
4 | -import com.sincere.quartz.third.yixueyun.YXYWriteService; | |
5 | -import org.springframework.beans.factory.annotation.Autowired; | |
6 | -import org.springframework.scheduling.annotation.Scheduled; | |
7 | -import org.springframework.stereotype.Service; | |
8 | - | |
9 | -/** | |
10 | - * @author chen | |
11 | - * @version 1.0 | |
12 | - * @date 2019/12/24 0024 10:54 | |
13 | - */ | |
14 | -@Service | |
15 | -public class SyncJob { | |
16 | - | |
17 | - @Autowired | |
18 | - YXYWriteService yxyWriteService; | |
19 | - | |
20 | - @Autowired | |
21 | - YXYReadService yxyReadService; | |
22 | - | |
23 | - @Scheduled(cron = "30 1 22 * * ? ") | |
24 | - public void Sync(){ | |
25 | - //翼校通的同步 之后还有钉钉的同步等等 | |
26 | - yxyReadService.sync(); | |
27 | - yxyWriteService.sync(); | |
28 | - } | |
29 | -} | |
1 | +//package com.sincere.quartz.job; | |
2 | +// | |
3 | +//import com.sincere.quartz.third.yixueyun.YXYReadService; | |
4 | +//import com.sincere.quartz.third.yixueyun.YXYWriteService; | |
5 | +//import org.springframework.beans.factory.annotation.Autowired; | |
6 | +//import org.springframework.scheduling.annotation.Scheduled; | |
7 | +//import org.springframework.stereotype.Service; | |
8 | +// | |
9 | +///** | |
10 | +// * @author chen | |
11 | +// * @version 1.0 | |
12 | +// * @date 2019/12/24 0024 10:54 | |
13 | +// */ | |
14 | +//@Service | |
15 | +//public class SyncJob { | |
16 | +// | |
17 | +// @Autowired | |
18 | +// YXYWriteService yxyWriteService; | |
19 | +// | |
20 | +// @Autowired | |
21 | +// YXYReadService yxyReadService; | |
22 | +// | |
23 | +// @Scheduled(cron = "30 1 22 * * ? ") | |
24 | +// public void Sync(){ | |
25 | +// //翼校通的同步 之后还有钉钉的同步等等 | |
26 | +// yxyReadService.sync(); | |
27 | +// yxyWriteService.sync(); | |
28 | +// } | |
29 | +//} | ... | ... |