Commit 021910193baa5c3e124a220235a347a97e2d40e4
1 parent
46eaf1b0
Exists in
master
考勤推送修改,绑定关注逻辑
Showing
35 changed files
with
1010 additions
and
546 deletions
Show diff stats
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/AppDto.java
... | ... | @@ -8,6 +8,8 @@ package com.sincere.common.dto.smartCampus; |
8 | 8 | public class AppDto { |
9 | 9 | private String agentId ; |
10 | 10 | private String agentSecret ; |
11 | + private String qyhId ; | |
12 | + private String agentKey ; | |
11 | 13 | |
12 | 14 | public String getAgentId() { |
13 | 15 | return agentId; |
... | ... | @@ -24,4 +26,20 @@ public class AppDto { |
24 | 26 | public void setAgentSecret(String agentSecret) { |
25 | 27 | this.agentSecret = agentSecret; |
26 | 28 | } |
29 | + | |
30 | + public String getQyhId() { | |
31 | + return qyhId; | |
32 | + } | |
33 | + | |
34 | + public void setQyhId(String qyhId) { | |
35 | + this.qyhId = qyhId; | |
36 | + } | |
37 | + | |
38 | + public String getAgentKey() { | |
39 | + return agentKey; | |
40 | + } | |
41 | + | |
42 | + public void setAgentKey(String agentKey) { | |
43 | + this.agentKey = agentKey; | |
44 | + } | |
27 | 45 | } | ... | ... |
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/BindPushDto.java
0 → 100644
... | ... | @@ -0,0 +1,73 @@ |
1 | +package com.sincere.common.dto.smartCampus; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/12/11 0011 16:56 | |
7 | + */ | |
8 | +public class BindPushDto { | |
9 | + | |
10 | + private int schoolId ; | |
11 | + private int type ; // 0是企业号,1是钉钉 | |
12 | + private String beginDate ; | |
13 | + private String endDate ; | |
14 | + private int intervalDays ; | |
15 | + private String pushTime ; | |
16 | + private String msg ; | |
17 | + | |
18 | + public int getSchoolId() { | |
19 | + return schoolId; | |
20 | + } | |
21 | + | |
22 | + public void setSchoolId(int schoolId) { | |
23 | + this.schoolId = schoolId; | |
24 | + } | |
25 | + | |
26 | + public int getType() { | |
27 | + return type; | |
28 | + } | |
29 | + | |
30 | + public void setType(int type) { | |
31 | + this.type = type; | |
32 | + } | |
33 | + | |
34 | + public String getBeginDate() { | |
35 | + return beginDate; | |
36 | + } | |
37 | + | |
38 | + public void setBeginDate(String beginDate) { | |
39 | + this.beginDate = beginDate; | |
40 | + } | |
41 | + | |
42 | + public String getEndDate() { | |
43 | + return endDate; | |
44 | + } | |
45 | + | |
46 | + public void setEndDate(String endDate) { | |
47 | + this.endDate = endDate; | |
48 | + } | |
49 | + | |
50 | + public int getIntervalDays() { | |
51 | + return intervalDays; | |
52 | + } | |
53 | + | |
54 | + public void setIntervalDays(int intervalDays) { | |
55 | + this.intervalDays = intervalDays; | |
56 | + } | |
57 | + | |
58 | + public String getPushTime() { | |
59 | + return pushTime; | |
60 | + } | |
61 | + | |
62 | + public void setPushTime(String pushTime) { | |
63 | + this.pushTime = pushTime; | |
64 | + } | |
65 | + | |
66 | + public String getMsg() { | |
67 | + return msg; | |
68 | + } | |
69 | + | |
70 | + public void setMsg(String msg) { | |
71 | + this.msg = msg; | |
72 | + } | |
73 | +} | ... | ... |
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/CensusKqDto.java
... | ... | @@ -6,49 +6,31 @@ package com.sincere.common.dto.smartCampus; |
6 | 6 | * @date 2019/11/29 0029 14:27 |
7 | 7 | */ |
8 | 8 | public class CensusKqDto { |
9 | - private int classId ; | |
10 | - private String className ; | |
11 | - private int allT ; | |
12 | - private int kqT ; | |
13 | - private int qjT ; | |
9 | + private String targetName ; | |
10 | + private int leaveCount ; | |
11 | + private int notAttendCount ; | |
14 | 12 | |
15 | - public int getClassId() { | |
16 | - return classId; | |
13 | + public String getTargetName() { | |
14 | + return targetName; | |
17 | 15 | } |
18 | 16 | |
19 | - public void setClassId(int classId) { | |
20 | - this.classId = classId; | |
17 | + public void setTargetName(String targetName) { | |
18 | + this.targetName = targetName; | |
21 | 19 | } |
22 | 20 | |
23 | - public String getClassName() { | |
24 | - return className; | |
21 | + public int getLeaveCount() { | |
22 | + return leaveCount; | |
25 | 23 | } |
26 | 24 | |
27 | - public void setClassName(String className) { | |
28 | - this.className = className; | |
25 | + public void setLeaveCount(int leaveCount) { | |
26 | + this.leaveCount = leaveCount; | |
29 | 27 | } |
30 | 28 | |
31 | - public int getAllT() { | |
32 | - return allT; | |
29 | + public int getNotAttendCount() { | |
30 | + return notAttendCount; | |
33 | 31 | } |
34 | 32 | |
35 | - public void setAllT(int allT) { | |
36 | - this.allT = allT; | |
37 | - } | |
38 | - | |
39 | - public int getKqT() { | |
40 | - return kqT; | |
41 | - } | |
42 | - | |
43 | - public void setKqT(int kqT) { | |
44 | - this.kqT = kqT; | |
45 | - } | |
46 | - | |
47 | - public int getQjT() { | |
48 | - return qjT; | |
49 | - } | |
50 | - | |
51 | - public void setQjT(int qjT) { | |
52 | - this.qjT = qjT; | |
33 | + public void setNotAttendCount(int notAttendCount) { | |
34 | + this.notAttendCount = notAttendCount; | |
53 | 35 | } |
54 | 36 | } | ... | ... |
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/KqTeacherDto.java
... | ... | @@ -11,11 +11,13 @@ public class KqTeacherDto { |
11 | 11 | private String name ; |
12 | 12 | private String mobile ; |
13 | 13 | private String pass ; |
14 | - private String DingUserId ; | |
15 | - private String weChatUserId ; | |
16 | 14 | private String openId ; |
17 | 15 | private String face ; |
18 | 16 | |
17 | + private int classId ; | |
18 | + private int roomId ; | |
19 | + private String targetName ; | |
20 | + | |
19 | 21 | public String getUserId() { |
20 | 22 | return userId; |
21 | 23 | } |
... | ... | @@ -56,22 +58,6 @@ public class KqTeacherDto { |
56 | 58 | this.pass = pass; |
57 | 59 | } |
58 | 60 | |
59 | - public String getDingUserId() { | |
60 | - return DingUserId; | |
61 | - } | |
62 | - | |
63 | - public void setDingUserId(String dingUserId) { | |
64 | - DingUserId = dingUserId; | |
65 | - } | |
66 | - | |
67 | - public String getWeChatUserId() { | |
68 | - return weChatUserId; | |
69 | - } | |
70 | - | |
71 | - public void setWeChatUserId(String weChatUserId) { | |
72 | - this.weChatUserId = weChatUserId; | |
73 | - } | |
74 | - | |
75 | 61 | public String getOpenId() { |
76 | 62 | return openId; |
77 | 63 | } |
... | ... | @@ -87,4 +73,28 @@ public class KqTeacherDto { |
87 | 73 | public void setFace(String face) { |
88 | 74 | this.face = face; |
89 | 75 | } |
76 | + | |
77 | + public int getClassId() { | |
78 | + return classId; | |
79 | + } | |
80 | + | |
81 | + public void setClassId(int classId) { | |
82 | + this.classId = classId; | |
83 | + } | |
84 | + | |
85 | + public int getRoomId() { | |
86 | + return roomId; | |
87 | + } | |
88 | + | |
89 | + public void setRoomId(int roomId) { | |
90 | + this.roomId = roomId; | |
91 | + } | |
92 | + | |
93 | + public String getTargetName() { | |
94 | + return targetName; | |
95 | + } | |
96 | + | |
97 | + public void setTargetName(String targetName) { | |
98 | + this.targetName = targetName; | |
99 | + } | |
90 | 100 | } | ... | ... |
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/ParentDto.java
0 → 100644
... | ... | @@ -0,0 +1,37 @@ |
1 | +package com.sincere.common.dto.smartCampus; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/12/10 0010 11:14 | |
7 | + */ | |
8 | +public class ParentDto { | |
9 | + | |
10 | + private int schoolId ; | |
11 | + private int parentId ; | |
12 | + private String mobile ; | |
13 | + | |
14 | + public int getSchoolId() { | |
15 | + return schoolId; | |
16 | + } | |
17 | + | |
18 | + public void setSchoolId(int schoolId) { | |
19 | + this.schoolId = schoolId; | |
20 | + } | |
21 | + | |
22 | + public int getParentId() { | |
23 | + return parentId; | |
24 | + } | |
25 | + | |
26 | + public void setParentId(int parentId) { | |
27 | + this.parentId = parentId; | |
28 | + } | |
29 | + | |
30 | + public String getMobile() { | |
31 | + return mobile; | |
32 | + } | |
33 | + | |
34 | + public void setMobile(String mobile) { | |
35 | + this.mobile = mobile; | |
36 | + } | |
37 | +} | ... | ... |
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/TemplateDto.java
... | ... | @@ -9,10 +9,19 @@ import java.io.Serializable; |
9 | 9 | */ |
10 | 10 | public class TemplateDto implements Serializable { |
11 | 11 | |
12 | + private int id ; | |
12 | 13 | private String config ; |
13 | 14 | private int schoolId ; |
14 | 15 | private String type ; |
15 | 16 | |
17 | + public int getId() { | |
18 | + return id; | |
19 | + } | |
20 | + | |
21 | + public void setId(int id) { | |
22 | + this.id = id; | |
23 | + } | |
24 | + | |
16 | 25 | public String getConfig() { |
17 | 26 | return config; |
18 | 27 | } | ... | ... |
cloud/common/src/main/java/com/sincere/common/enums/PushTypeEnums.java
0 → 100644
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.sincere.common.enums; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/12/10 0010 11:30 | |
7 | + */ | |
8 | +public enum PushTypeEnums { | |
9 | + | |
10 | + WEB(0,"站内消息"), | |
11 | + APP(1,"APP消息"), | |
12 | + MESSAGE(2,"短消息"), | |
13 | + WECHAT(3,"微信公众号"), | |
14 | + DING(4,"盯盯消息"), | |
15 | + QIYEHAO(5,"企业号消息"); | |
16 | + | |
17 | + private int type ; | |
18 | + private String name ; | |
19 | + | |
20 | + PushTypeEnums(int type, String name) { | |
21 | + this.type = type; | |
22 | + this.name = name; | |
23 | + } | |
24 | + | |
25 | + public int getType() { | |
26 | + return type; | |
27 | + } | |
28 | + | |
29 | + public void setType(int type) { | |
30 | + this.type = type; | |
31 | + } | |
32 | + | |
33 | + public String getName() { | |
34 | + return name; | |
35 | + } | |
36 | + | |
37 | + public void setName(String name) { | |
38 | + this.name = name; | |
39 | + } | |
40 | +} | ... | ... |
cloud/common/src/main/java/com/sincere/common/util/DateUtils.java
... | ... | @@ -18,6 +18,10 @@ public class DateUtils { |
18 | 18 | |
19 | 19 | public static String format2 = "yyyy-MM-dd HH:mm:ss"; |
20 | 20 | |
21 | + public static String format3 = "yyyyMMddHHmm" ; | |
22 | + | |
23 | + public static String format4 = "HH:mm" ; | |
24 | + | |
21 | 25 | public static long getDate(){ |
22 | 26 | return System.currentTimeMillis(); |
23 | 27 | } | ... | ... |
cloud/common/src/main/java/com/sincere/common/util/HttpClientUtils.java
1 | 1 | package com.sincere.common.util; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSONArray; | |
3 | 4 | import com.alibaba.fastjson.JSONObject; |
4 | 5 | import org.apache.http.HttpEntity; |
5 | 6 | import org.apache.http.HttpStatus; |
... | ... | @@ -17,6 +18,7 @@ import java.io.IOException; |
17 | 18 | import java.io.InputStream; |
18 | 19 | import java.net.HttpURLConnection; |
19 | 20 | import java.net.URL; |
21 | +import java.util.Date; | |
20 | 22 | |
21 | 23 | /** |
22 | 24 | * HttpClient4.3工具类 |
... | ... | @@ -28,14 +30,20 @@ public class HttpClientUtils { |
28 | 30 | |
29 | 31 | private static RequestConfig requestConfig = null; |
30 | 32 | |
31 | - static | |
32 | - { | |
33 | + static { | |
33 | 34 | // 设置请求和传输超时时间 |
34 | 35 | requestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).build(); |
35 | 36 | } |
36 | 37 | |
37 | 38 | public static void main(String[] args){ |
38 | - JSONObject teacherList = HttpClientUtils.httpGet("http://60.190.202.57:1000/api/EasyN/GetSchoolSubject?SchoolId=1"); | |
39 | +// JSONObject object = HttpClientUtils.httpGet("http://60.190.202.57:1000/api/EasyN/GeAttendDetailNew?Id=158&TemplateId=0IZBD9624P&Type=0&time=2019-12-12&UserId=P113111&SchoolId=16"); | |
40 | +// JSONArray data = (JSONArray)object.get("data"); | |
41 | + String msg = "[{\"stuCount\":393,\"stuAttendCount\":341,\"noAttendCount\":52,\"sNoAttendCount\":52,\"leaveCount\":0,\"state\":\"已结束\",\"id\":310,\"templateId\":\"OCQQMV0ZXM\",\"color\":3}]"; | |
42 | + JSONArray data = JSONArray.parseArray(msg); | |
43 | + for(int i = 0 ; i < data.size() ; i++){ | |
44 | + JSONObject object = data.getJSONObject(i); | |
45 | + System.out.println(object.get("stuCount")); | |
46 | + } | |
39 | 47 | System.out.println("1"); |
40 | 48 | } |
41 | 49 | |
... | ... | @@ -45,7 +53,7 @@ public class HttpClientUtils { |
45 | 53 | * @param jsonParam 参数 |
46 | 54 | * @return |
47 | 55 | */ |
48 | - public static JSONObject httpPost(String url, JSONObject jsonParam) { | |
56 | + public static JSONObject httpPostJson(String url, String jsonParam) { | |
49 | 57 | // post请求返回结果 |
50 | 58 | CloseableHttpClient httpClient = HttpClients.createDefault(); |
51 | 59 | JSONObject jsonResult = null; |
... | ... | @@ -55,7 +63,7 @@ public class HttpClientUtils { |
55 | 63 | try { |
56 | 64 | if (null != jsonParam) { |
57 | 65 | // 解决中文乱码问题 |
58 | - StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8"); | |
66 | + StringEntity entity = new StringEntity(jsonParam, "utf-8"); | |
59 | 67 | entity.setContentEncoding("UTF-8"); |
60 | 68 | entity.setContentType("application/json"); |
61 | 69 | httpPost.setEntity(entity); | ... | ... |
No preview for this file type
cloud/quartz/pom.xml
... | ... | @@ -13,6 +13,13 @@ |
13 | 13 | |
14 | 14 | <dependencies> |
15 | 15 | <dependency> |
16 | + <groupId>taobao-sdk-java-auto</groupId> | |
17 | + <artifactId>ding</artifactId> | |
18 | + <scope>system</scope> | |
19 | + <version>1</version> | |
20 | + <systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1479188381469-20191205.jar</systemPath> | |
21 | + </dependency> | |
22 | + <dependency> | |
16 | 23 | <groupId>com.sincere</groupId> |
17 | 24 | <artifactId>common</artifactId> |
18 | 25 | <version>1.0.0</version> | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/feign/ScFeign.java
... | ... | @@ -7,7 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping; |
7 | 7 | import org.springframework.web.bind.annotation.RequestMethod; |
8 | 8 | import org.springframework.web.bind.annotation.RequestParam; |
9 | 9 | |
10 | +import java.util.HashMap; | |
10 | 11 | import java.util.List; |
12 | +import java.util.Map; | |
11 | 13 | |
12 | 14 | /** |
13 | 15 | * @author chen |
... | ... | @@ -17,6 +19,7 @@ import java.util.List; |
17 | 19 | @FeignClient("smartCampusSearch") |
18 | 20 | public interface ScFeign { |
19 | 21 | |
22 | + //考勤推送 | |
20 | 23 | @RequestMapping(value = "/sm/kq/getAllTemplate",method = RequestMethod.GET) |
21 | 24 | List<TemplateDto> getAllTemplate(); |
22 | 25 | |
... | ... | @@ -29,9 +32,17 @@ public interface ScFeign { |
29 | 32 | @RequestMapping(value = "/sm/kq/getApp",method = RequestMethod.GET) |
30 | 33 | AppDto getApp(@RequestParam("schoolId")int schoolId , @RequestParam("type") int type); |
31 | 34 | |
32 | - @RequestMapping(value = "/sm/kq/getCensusKq",method = RequestMethod.POST) | |
33 | - List<CensusKqDto> getCensusKq(@RequestBody KqDto kqDto); | |
35 | + @RequestMapping(value = "/sm/kq/getThirdId",method = RequestMethod.GET) | |
36 | + String getThirdId(@RequestParam("userId")String userId , @RequestParam("type") int type); | |
34 | 37 | |
35 | - @RequestMapping(value = "/sm/kq/selectCensusChamberKq",method = RequestMethod.POST) | |
36 | - List<CensusKqDto> selectCensusChamberKq(@RequestBody KqDto kqDto); | |
38 | + | |
39 | + //关注绑定推送 | |
40 | + @RequestMapping(value = "/sm/rp/selectBindPushSchool",method = RequestMethod.GET) | |
41 | + List<BindPushDto> selectBindPushSchool(); | |
42 | + | |
43 | + @RequestMapping(value = "/sm/rp/selectNotFollow",method = RequestMethod.GET) | |
44 | + List<ParentDto> selectNotFollow(@RequestParam("schoolId") int schoolId); | |
45 | + | |
46 | + @RequestMapping(value = "/sm/rp/selectNotBind",method = RequestMethod.GET) | |
47 | + List<ParentDto> selectNotBind(@RequestParam("schoolId") int schoolId , @RequestParam("type") int type); | |
37 | 48 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/BindPushJob.java
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
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 org.apache.commons.lang3.StringUtils; | |
9 | +import org.springframework.beans.factory.annotation.Autowired; | |
10 | +import org.springframework.scheduling.annotation.Scheduled; | |
11 | +import org.springframework.stereotype.Service; | |
12 | + | |
13 | +import java.util.*; | |
14 | + | |
15 | +/** | |
16 | + * 用户注册激活提醒 | |
17 | + * @author chen | |
18 | + * @version 1.0 | |
19 | + * @date 2019/12/10 0010 8:31 | |
20 | + */ | |
21 | +@Service | |
22 | +public class BindPushJob { | |
23 | + | |
24 | + @Autowired | |
25 | + ScFeign scFeign; | |
26 | + | |
27 | + private static String date ; | |
28 | + private static List<BindPushDto> schoolList = new ArrayList<>(); | |
29 | + private static Map<Integer , String> intervalDaysMap = new HashMap<>(); | |
30 | + | |
31 | + @Scheduled(cron = "0 0-59 * * * ? ") | |
32 | + public void bindPush(){ | |
33 | + Date nowDate = new Date(); | |
34 | + String now = DateUtils.date2String(nowDate,DateUtils.format1) ; | |
35 | + if(StringUtils.isBlank(date) || !date.equals(now)){ | |
36 | + initMap(now); | |
37 | + } | |
38 | + for(BindPushDto school : schoolList){ | |
39 | + int i =DateUtils.string2Date(school.getBeginDate(),DateUtils.format1).compareTo(nowDate) ; | |
40 | + int j = DateUtils.string2Date(school.getEndDate(),DateUtils.format1).compareTo(nowDate) ; | |
41 | + if(DateUtils.string2Date(school.getBeginDate(),DateUtils.format1).compareTo(nowDate) <= 0 | |
42 | + && DateUtils.string2Date(school.getEndDate(),DateUtils.format1).compareTo(nowDate) >= 0){ | |
43 | + String lastDate = intervalDaysMap.get(school.getSchoolId()); | |
44 | + if(StringUtils.isBlank(lastDate)){ | |
45 | + //下发推送 | |
46 | + bindPush(school,nowDate); | |
47 | + }else { | |
48 | + int day = DateUtils.getDateDifference(nowDate,DateUtils.string2Date(lastDate,DateUtils.format1),"day") ; | |
49 | + if(day == school.getIntervalDays() + 1) { | |
50 | + //下发推送 | |
51 | + bindPush(school,nowDate); | |
52 | + } | |
53 | + } | |
54 | + } | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + private void bindPush(BindPushDto bindPushDto , Date nowDate){ | |
59 | + if(bindPushDto.getPushTime().equals(DateUtils.date2String(nowDate,DateUtils.format4))){ | |
60 | + List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId()); | |
61 | + | |
62 | + List<ParentDto> unBindList =scFeign.selectNotBind(bindPushDto.getSchoolId(),getThirdType(bindPushDto.getType())); | |
63 | + | |
64 | + intervalDaysMap.put(bindPushDto.getSchoolId(),DateUtils.date2String(nowDate,DateUtils.format1)); | |
65 | + } | |
66 | + } | |
67 | + | |
68 | + private void initMap(String now){ | |
69 | + date = now ; | |
70 | + //schoolList = scFeign.selectBindPushSchool(); | |
71 | + BindPushDto bindPushDto = new BindPushDto(); | |
72 | + bindPushDto.setSchoolId(16); | |
73 | + bindPushDto.setBeginDate("2019-12-04"); | |
74 | + bindPushDto.setEndDate("2019-12-30"); | |
75 | + bindPushDto.setIntervalDays(1); | |
76 | + bindPushDto.setPushTime("11:04"); | |
77 | + bindPushDto.setType(0); | |
78 | + bindPushDto.setMsg(""); | |
79 | + schoolList = new ArrayList<>(); | |
80 | + schoolList.add(bindPushDto); | |
81 | + } | |
82 | + | |
83 | + private int getThirdType(int type){ | |
84 | + if(type == 0){ | |
85 | + return PushTypeEnums.DING.getType() ; | |
86 | + }else { | |
87 | + return PushTypeEnums.QIYEHAO.getType() ; | |
88 | + } | |
89 | + } | |
90 | + | |
91 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
1 | 1 | package com.sincere.quartz.job; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSONArray; | |
4 | +import com.alibaba.fastjson.JSONObject; | |
3 | 5 | import com.sincere.common.dto.smartCampus.*; |
6 | +import com.sincere.common.enums.PushTypeEnums; | |
4 | 7 | import com.sincere.common.util.DateUtils; |
8 | +import com.sincere.common.util.HttpClientUtils; | |
5 | 9 | import com.sincere.quartz.enums.KqTypeEnums; |
6 | 10 | import com.sincere.quartz.enums.TypeEnums; |
7 | 11 | import com.sincere.quartz.feign.ScFeign; |
... | ... | @@ -38,7 +42,7 @@ public class KQJob { |
38 | 42 | private static String date ; |
39 | 43 | private static Map<String , String> map = new HashMap<>(); |
40 | 44 | |
41 | - @Scheduled(cron = "* 0/1 * * * ?") | |
45 | + @Scheduled(cron = "0 0-59 * * * ? ") | |
42 | 46 | public void kaoQing() { |
43 | 47 | String now = DateUtils.date2String(new Date(),DateUtils.format1) ; |
44 | 48 | if(StringUtils.isBlank(date)){ |
... | ... | @@ -54,14 +58,14 @@ public class KQJob { |
54 | 58 | for(Map.Entry<String, String> entity : map.entrySet()){ |
55 | 59 | String endTime = entity.getValue().split("_")[1]; |
56 | 60 | if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")>=2 |
57 | - && DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m") < 5){ | |
61 | + ){ | |
58 | 62 | String key = entity.getKey(); |
59 | 63 | String[] messageArray = key.split("_"); |
60 | - if(messageArray[2].contains("5")){ | |
64 | + if(messageArray[2].contains(PushTypeEnums.QIYEHAO.getType()+"")){ | |
61 | 65 | logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]); |
62 | - weChatBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue()); | |
66 | + //weChatBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue()); | |
63 | 67 | } |
64 | - if(messageArray[2].contains("4")){ | |
68 | + if(messageArray[2].contains(PushTypeEnums.DING.getType()+"")){ | |
65 | 69 | logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1])); |
66 | 70 | dingBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue()); |
67 | 71 | } |
... | ... | @@ -73,6 +77,7 @@ public class KQJob { |
73 | 77 | } |
74 | 78 | } |
75 | 79 | |
80 | + //初始化要推送的模板 | |
76 | 81 | private void initMap(){ |
77 | 82 | map = new HashMap<>(); |
78 | 83 | List<TemplateDto> list = scFeign.getAllTemplate(); |
... | ... | @@ -92,7 +97,7 @@ public class KQJob { |
92 | 97 | int nowWeek = DateUtils.getWeek() ; |
93 | 98 | if(Week.contains(nowWeek+"")){ |
94 | 99 | logger.info((templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getType()+"------"+beginTime+"_"+endTime)); |
95 | - map.put(templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getType() , beginTime+"_"+endTime+"_"+type); | |
100 | + map.put(templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getType() , beginTime+"_"+endTime+"_"+type+"_"+templateDto.getId()); | |
96 | 101 | } |
97 | 102 | }catch (Exception e){ |
98 | 103 | e.printStackTrace(); |
... | ... | @@ -101,6 +106,7 @@ public class KQJob { |
101 | 106 | } |
102 | 107 | } |
103 | 108 | |
109 | + //盯盯批量推送 | |
104 | 110 | private void dingBatchPush(String templateId , int schoolId , String key){ |
105 | 111 | String[] times = key.split("_"); |
106 | 112 | AppDto appDto = scFeign.getApp(schoolId,1); |
... | ... | @@ -116,17 +122,18 @@ public class KQJob { |
116 | 122 | List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); |
117 | 123 | for(KqTeacherDto teacher : list){ |
118 | 124 | logger.info("盯盯推送班主任—————" + templateId + "--------" + teacher.getName()); |
119 | - dingSchoolPush(templateId,teacher, key, appDto); | |
125 | + //dingSchoolPush(templateId,teacher, key, appDto); | |
120 | 126 | } |
121 | 127 | //推宿管 |
122 | 128 | List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); |
123 | 129 | for(KqTeacherDto teacher : chamberList){ |
124 | 130 | logger.info("盯盯推送宿管—————" + templateId + "--------" + teacher.getName()); |
125 | - dingChamberPush(templateId,teacher, key, appDto); | |
131 | + //dingChamberPush(templateId,teacher, key, appDto); | |
126 | 132 | } |
127 | 133 | } |
128 | 134 | } |
129 | 135 | |
136 | + //企业号批量推送 | |
130 | 137 | private void weChatBatchPush(String templateId , int schoolId , String key){ |
131 | 138 | String[] times = key.split("_"); |
132 | 139 | AppDto appDto = scFeign.getApp(schoolId, 0); |
... | ... | @@ -153,22 +160,17 @@ public class KQJob { |
153 | 160 | } |
154 | 161 | } |
155 | 162 | |
163 | + //盯盯推送班主任 | |
156 | 164 | private void dingSchoolPush(String templateId ,KqTeacherDto teacher , String key , AppDto appDto){ |
157 | 165 | String[] times = key.split("_"); |
158 | 166 | String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); |
159 | - if(StringUtils.isNotBlank(teacher.getDingUserId())){ | |
160 | - KqDto dto = new KqDto(); | |
161 | - dto.setEndTime(times[1]); | |
162 | - dto.setTemplateId(templateId); | |
163 | - dto.setType(times[2]); | |
164 | - dto.setUserId(teacher.getUserId()); | |
165 | - List<CensusKqDto> censusKqDtos = scFeign.getCensusKq(dto); | |
167 | + String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),0); | |
168 | + if(StringUtils.isNotBlank(thirdOpenId)){ | |
169 | + List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1); | |
166 | 170 | if(censusKqDtos != null &&censusKqDtos.size() > 0){ |
167 | 171 | String message = ""; |
168 | 172 | for(CensusKqDto censusKqDto : censusKqDtos){ |
169 | - int number = censusKqDto.getAllT() - censusKqDto.getKqT()-censusKqDto.getQjT() ; | |
170 | - number = number < 0?0:number ; | |
171 | - message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人,请假"+censusKqDto.getQjT()+"人;"; | |
173 | + message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;"; | |
172 | 174 | } |
173 | 175 | DingSms dingSms = new DingSms(); |
174 | 176 | dingSms.setName(teacher.getName()); |
... | ... | @@ -179,36 +181,30 @@ public class KQJob { |
179 | 181 | "整体数据:" + message); |
180 | 182 | String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + |
181 | 183 | "schoolid="+teacher.getSchoolId()+"&userId="+teacher.getUserId()+"&name="+teacher.getName()+ "&TemplateId=" + templateId+ |
182 | - "&data="+teacher.getDingUserId()+"&type=1&stype=4&mobile="+teacher.getMobile()+"&pass="+teacher.getPass()+ | |
184 | + "&data="+thirdOpenId+"&type=1&stype=4&mobile="+teacher.getMobile()+"&pass="+teacher.getPass()+ | |
183 | 185 | "&face=&sourcetype=16&soutype=3×tamp="+ DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1) ; |
184 | 186 | dingSms.setSchoolId(teacher.getSchoolId()); |
185 | - dingSms.setDingUserId(teacher.getDingUserId()); | |
187 | + dingSms.setDingUserId(thirdOpenId); | |
186 | 188 | dingSms.setAgentId(appDto.getAgentId()); |
187 | 189 | dingSms.setWapUrl(wapUrl); |
188 | 190 | dingSms.setReceiveUserId(teacher.getUserId()); |
189 | 191 | dingSms.setTdType(TypeEnums.kaoqing.getType()); |
190 | - smsMapper.insertDing(dingSms); | |
192 | + this.insertDing(dingSms); | |
191 | 193 | } |
192 | 194 | } |
193 | 195 | } |
194 | 196 | |
197 | + //盯盯推送宿管 | |
195 | 198 | private void dingChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){ |
196 | 199 | String[] times = key.split("_"); |
197 | 200 | String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); |
198 | - if(StringUtils.isNotBlank(teacher.getDingUserId())){ | |
199 | - List<CensusKqDto> censusKqDtos ; | |
200 | - KqDto dto = new KqDto(); | |
201 | - dto.setEndTime(times[1]); | |
202 | - dto.setTemplateId(templateId); | |
203 | - dto.setType(times[2]); | |
204 | - dto.setUserId(teacher.getUserId()); | |
205 | - censusKqDtos = scFeign.selectCensusChamberKq(dto); | |
201 | + String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),0); | |
202 | + if(StringUtils.isNotBlank(thirdOpenId)){ | |
203 | + List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1); | |
206 | 204 | if(censusKqDtos != null &&censusKqDtos.size() > 0){ |
207 | 205 | String message = ""; |
208 | 206 | for(CensusKqDto censusKqDto : censusKqDtos){ |
209 | - int number = censusKqDto.getAllT() - censusKqDto.getKqT()-censusKqDto.getQjT() ; | |
210 | - number = number < 0?0:number ; | |
211 | - message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人,请假"+censusKqDto.getQjT()+"人;"; | |
207 | + message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;"; | |
212 | 208 | } |
213 | 209 | DingSms dingSms = new DingSms(); |
214 | 210 | dingSms.setName(teacher.getName()); |
... | ... | @@ -221,32 +217,27 @@ public class KQJob { |
221 | 217 | "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +"&TemplateId=" + templateId+ |
222 | 218 | "&pass=" + teacher.getPass() + "&type=4&soutype=3&time="+DateUtils.date2String(new Date(),DateUtils.format1); |
223 | 219 | dingSms.setSchoolId(teacher.getSchoolId()); |
224 | - dingSms.setDingUserId(teacher.getDingUserId()); | |
220 | + dingSms.setDingUserId(thirdOpenId); | |
225 | 221 | dingSms.setAgentId(appDto.getAgentId()); |
226 | 222 | dingSms.setWapUrl(msgUrl); |
227 | 223 | dingSms.setReceiveUserId(teacher.getUserId()); |
228 | 224 | dingSms.setTdType(TypeEnums.kaoqing.getType()); |
229 | - smsMapper.insertDing(dingSms); | |
225 | + this.insertDing(dingSms); | |
230 | 226 | } |
231 | 227 | } |
232 | 228 | } |
233 | 229 | |
230 | + //企业号推送班主任 | |
234 | 231 | private void weChatSchoolPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){ |
235 | 232 | String[] times = key.split("_"); |
236 | 233 | String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); |
237 | - if (StringUtils.isNotBlank(teacher.getOpenId())) { | |
238 | - KqDto dto = new KqDto(); | |
239 | - dto.setEndTime(times[1]); | |
240 | - dto.setTemplateId(templateId); | |
241 | - dto.setType(times[2]); | |
242 | - dto.setUserId(teacher.getUserId()); | |
243 | - List<CensusKqDto> censusKqDtos = scFeign.getCensusKq(dto); | |
234 | + String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),1); | |
235 | + if (StringUtils.isNotBlank(thirdOpenId)) { | |
236 | + List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1); | |
244 | 237 | if (censusKqDtos != null && censusKqDtos.size() > 0) { |
245 | 238 | String message = ""; |
246 | 239 | for (CensusKqDto censusKqDto : censusKqDtos) { |
247 | - int number = censusKqDto.getAllT() - censusKqDto.getKqT()-censusKqDto.getQjT() ; | |
248 | - number = number < 0?0:number ; | |
249 | - message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人,请假"+censusKqDto.getQjT()+"人;"; | |
240 | + message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;"; | |
250 | 241 | } |
251 | 242 | WeChatSms weChatSms = new WeChatSms(); |
252 | 243 | weChatSms.setTableName("qyhSmsNew" + tableSuffix); |
... | ... | @@ -256,38 +247,32 @@ public class KQJob { |
256 | 247 | "整体数据:" + message); |
257 | 248 | weChatSms.setSchoolId(teacher.getSchoolId()); |
258 | 249 | weChatSms.setName(teacher.getName()); |
259 | - weChatSms.setQiYeHaoUserId(teacher.getWeChatUserId()); | |
250 | + weChatSms.setQiYeHaoUserId(thirdOpenId); | |
260 | 251 | weChatSms.setReceiveUserId(teacher.getUserId()); |
261 | 252 | weChatSms.setAppId(appDto.getAgentId()); |
262 | 253 | weChatSms.setSecret(appDto.getAgentSecret()); |
263 | 254 | String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + |
264 | 255 | "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +"&TemplateId=" + templateId+ |
265 | - "&data=" + teacher.getWeChatUserId() + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + | |
256 | + "&data=" + thirdOpenId + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + | |
266 | 257 | "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2×tamp=" + DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1)+"&"; |
267 | 258 | weChatSms.setMsgUrl(msgUrl); |
268 | 259 | weChatSms.setTdType(TypeEnums.kaoqing.getType()); |
269 | - smsMapper.insertWeChat(weChatSms); | |
260 | + this.insertQYH(weChatSms); | |
270 | 261 | } |
271 | 262 | } |
272 | 263 | } |
273 | 264 | |
265 | + //企业号推送宿管 | |
274 | 266 | private void weChatChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){ |
275 | 267 | String[] times = key.split("_"); |
276 | 268 | String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); |
277 | - if (StringUtils.isNotBlank(teacher.getOpenId())) { | |
278 | - List<CensusKqDto> censusKqDtos ; | |
279 | - KqDto dto = new KqDto(); | |
280 | - dto.setEndTime(times[1]); | |
281 | - dto.setTemplateId(templateId); | |
282 | - dto.setType(times[2]); | |
283 | - dto.setUserId(teacher.getUserId()); | |
284 | - censusKqDtos = scFeign.selectCensusChamberKq(dto); | |
269 | + String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),1); | |
270 | + if (StringUtils.isNotBlank(thirdOpenId)) { | |
271 | + List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1); | |
285 | 272 | if (censusKqDtos != null && censusKqDtos.size() > 0) { |
286 | 273 | String message = ""; |
287 | 274 | for (CensusKqDto censusKqDto : censusKqDtos) { |
288 | - int number = censusKqDto.getAllT() - censusKqDto.getKqT()-censusKqDto.getQjT() ; | |
289 | - number = number < 0?0:number ; | |
290 | - message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人,请假"+censusKqDto.getQjT()+"人;"; | |
275 | + message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;"; | |
291 | 276 | } |
292 | 277 | WeChatSms weChatSms = new WeChatSms(); |
293 | 278 | weChatSms.setTableName("qyhSmsNew" + tableSuffix); |
... | ... | @@ -297,7 +282,7 @@ public class KQJob { |
297 | 282 | "整体数据:" + message); |
298 | 283 | weChatSms.setSchoolId(teacher.getSchoolId()); |
299 | 284 | weChatSms.setName(teacher.getName()); |
300 | - weChatSms.setQiYeHaoUserId(teacher.getWeChatUserId()); | |
285 | + weChatSms.setQiYeHaoUserId(thirdOpenId); | |
301 | 286 | weChatSms.setReceiveUserId(teacher.getUserId()); |
302 | 287 | weChatSms.setAppId(appDto.getAgentId()); |
303 | 288 | weChatSms.setSecret(appDto.getAgentSecret()); |
... | ... | @@ -306,8 +291,46 @@ public class KQJob { |
306 | 291 | "&pass=" + teacher.getPass() + "&type=4&soutype=2&time="+DateUtils.date2String(new Date(),DateUtils.format1)+"&"; |
307 | 292 | weChatSms.setMsgUrl(msgUrl); |
308 | 293 | weChatSms.setTdType(TypeEnums.kaoqing.getType()); |
309 | - smsMapper.insertWeChat(weChatSms); | |
294 | + this.insertQYH(weChatSms); | |
310 | 295 | } |
311 | 296 | } |
312 | 297 | } |
298 | + | |
299 | + //type 0 出入校 1 出入寝 | |
300 | + private List<CensusKqDto> getCensus(int id , String templateId ,int schoolId , String userId ,int type){ | |
301 | + List<CensusKqDto> list = new ArrayList<>(); | |
302 | + CensusKqDto censusKqDto = new CensusKqDto(); | |
303 | + String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetailNew?schoolId="+schoolId+ | |
304 | + "&id="+id+"&templateID="+templateId+"&type="+type+"&userId="+userId+"&time=" + DateUtils.date2String(new Date(),DateUtils.format1); | |
305 | + JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
306 | + try{ | |
307 | + JSONArray data = (JSONArray)jsonObject.get("data"); | |
308 | + for(int i = 0 ; i < data.size() ; i++){ | |
309 | + JSONObject object = data.getJSONObject(i); | |
310 | + censusKqDto.setLeaveCount((Integer) object.get("leaveCount")); | |
311 | + censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount")); | |
312 | + censusKqDto.setTargetName((String)object.get("name")); | |
313 | + } | |
314 | + list.add(censusKqDto); | |
315 | + }catch (Exception e){ | |
316 | + | |
317 | + } | |
318 | + return list ; | |
319 | + } | |
320 | + | |
321 | + private void insertDing(DingSms dingSms){ | |
322 | + try{ | |
323 | + smsMapper.insertDing(dingSms); | |
324 | + }catch (Exception e){ | |
325 | + logger.info(e.toString()); | |
326 | + } | |
327 | + } | |
328 | + | |
329 | + private void insertQYH(WeChatSms weChatSms){ | |
330 | + try{ | |
331 | + smsMapper.insertWeChat(weChatSms); | |
332 | + }catch (Exception e){ | |
333 | + logger.info(e.toString()); | |
334 | + } | |
335 | + } | |
313 | 336 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/KqController.java
... | ... | @@ -27,6 +27,7 @@ public class KqController { |
27 | 27 | List<TemplateDto> templateDtos = new ArrayList<>(); |
28 | 28 | for(KqTemplate kqTemplate : list){ |
29 | 29 | TemplateDto templateDto = new TemplateDto(); |
30 | + templateDto.setId(kqTemplate.getId()); | |
30 | 31 | templateDto.setConfig(kqTemplate.getConfig()); |
31 | 32 | templateDto.setSchoolId(kqTemplate.getSchoolId()); |
32 | 33 | templateDto.setType(kqTemplate.getType()); |
... | ... | @@ -54,13 +55,11 @@ public class KqController { |
54 | 55 | return kqService.selectApp(map); |
55 | 56 | } |
56 | 57 | |
57 | - @RequestMapping(value = "getCensusKq",method = RequestMethod.POST) | |
58 | - public List<CensusKqDto> getCensusKq(@RequestBody KqDto kqDto){ | |
59 | - return kqService.selectCensusKq(kqDto); | |
60 | - } | |
61 | - | |
62 | - @RequestMapping(value = "selectCensusChamberKq",method = RequestMethod.POST) | |
63 | - public List<CensusKqDto> selectCensusChamberKq(@RequestBody KqDto kqDto){ | |
64 | - return kqService.selectCensusChamberKq(kqDto); | |
58 | + @RequestMapping(value = "getThirdId",method = RequestMethod.GET) | |
59 | + public String getThirdId(@RequestParam("userId")String userId , @RequestParam("type") int type){ | |
60 | + Map<String ,String> map = new HashMap<>(); | |
61 | + map.put("userId",userId); | |
62 | + map.put("type",type+""); | |
63 | + return kqService.selectThirdId(map); | |
65 | 64 | } |
66 | 65 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/RegisterPushController.java
0 → 100644
... | ... | @@ -0,0 +1,50 @@ |
1 | +package com.sincere.smartSearch.controller; | |
2 | + | |
3 | +import com.sincere.common.dto.smartCampus.BindPushDto; | |
4 | +import com.sincere.common.dto.smartCampus.ParentDto; | |
5 | +import com.sincere.smartSearch.service.RegisterPushService; | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.web.bind.annotation.RequestMapping; | |
8 | +import org.springframework.web.bind.annotation.RequestMethod; | |
9 | +import org.springframework.web.bind.annotation.RequestParam; | |
10 | +import org.springframework.web.bind.annotation.RestController; | |
11 | + | |
12 | +import java.util.HashMap; | |
13 | +import java.util.List; | |
14 | +import java.util.Map; | |
15 | + | |
16 | +/** | |
17 | + * @author chen | |
18 | + * @version 1.0 | |
19 | + * @date 2019/12/10 0010 11:20 | |
20 | + */ | |
21 | +@RestController | |
22 | +@RequestMapping("/sm/rp") | |
23 | +public class RegisterPushController { | |
24 | + | |
25 | + @Autowired | |
26 | + RegisterPushService registerPushService ; | |
27 | + | |
28 | + @RequestMapping(value = "selectBindPushSchool",method = RequestMethod.GET) | |
29 | + List<BindPushDto> selectBindPushSchool(){ | |
30 | + return registerPushService.selectBindPushSchool(); | |
31 | + } | |
32 | + | |
33 | + @RequestMapping(value = "selectNotFollow",method = RequestMethod.GET) | |
34 | + List<ParentDto> selectNotFollow(@RequestParam("schoolId") int schoolId){ | |
35 | + return registerPushService.selectNotFollow(schoolId); | |
36 | + } | |
37 | + | |
38 | + @RequestMapping(value = "selectFollow",method = RequestMethod.GET) | |
39 | + List<ParentDto> selectFollow(@RequestParam("schoolId") int schoolId){ | |
40 | + return registerPushService.selectFollow(schoolId); | |
41 | + } | |
42 | + | |
43 | + @RequestMapping(value = "selectNotBind",method = RequestMethod.GET) | |
44 | + List<ParentDto> selectNotBind(@RequestParam("schoolId") int schoolId , @RequestParam("type") int type){ | |
45 | + Map<String , Integer> map = new HashMap<>(); | |
46 | + map.put("schoolId",schoolId); | |
47 | + map.put("type",type); | |
48 | + return registerPushService.selectNotBind(map); | |
49 | + } | |
50 | +} | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/KqTemplateMapper.java
... | ... | @@ -24,25 +24,6 @@ public interface KqTemplateMapper { |
24 | 24 | |
25 | 25 | AppDto selectApp(Map<String,Integer> map); |
26 | 26 | |
27 | - List<CensusKqDto> selectCensusKq(Map<String ,String> map); | |
27 | + String selectThirdId(Map<String,String> map); | |
28 | 28 | |
29 | - List<KqChamber> selectChamberName(String userId); | |
30 | - | |
31 | - int selectChamberAllKq(Map<String,String> map); | |
32 | - | |
33 | - int selectChamberTrueKq(Map<String,String> map); | |
34 | - | |
35 | - int selectClassDealDateCHUQIN(Map<String,String> map); | |
36 | - | |
37 | - int selectClassDealDateQINGJIA(Map<String,String> map); | |
38 | - | |
39 | - int selectClassLeave(Map<String,String> map); | |
40 | - | |
41 | - int selectChamberDealDateCHUQIN(Map<String,String> map); | |
42 | - | |
43 | - int selectChamberDealDateQINGJIA(Map<String,String> map); | |
44 | - | |
45 | - int selectChamberLeave(Map<String,String> map); | |
46 | - | |
47 | - int selectClassChamberNumber(int classId); | |
48 | 29 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/RegisterPushMapper.java
0 → 100644
... | ... | @@ -0,0 +1,23 @@ |
1 | +package com.sincere.smartSearch.mapper; | |
2 | + | |
3 | +import com.sincere.common.dto.smartCampus.BindPushDto; | |
4 | +import com.sincere.common.dto.smartCampus.ParentDto; | |
5 | + | |
6 | +import java.util.List; | |
7 | +import java.util.Map; | |
8 | + | |
9 | +/** | |
10 | + * @author chen | |
11 | + * @version 1.0 | |
12 | + * @date 2019/12/10 0010 10:26 | |
13 | + */ | |
14 | +public interface RegisterPushMapper { | |
15 | + | |
16 | + List<BindPushDto> selectBindPushSchool(); | |
17 | + | |
18 | + List<ParentDto> selectNotFollow(int schoolId) ; | |
19 | + | |
20 | + List<ParentDto> selectFollow(int schoolId) ; | |
21 | + | |
22 | + List<ParentDto> selectNotBind(Map<String , Integer> map); | |
23 | +} | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/model/KqTemplate.java
... | ... | @@ -7,10 +7,19 @@ package com.sincere.smartSearch.model; |
7 | 7 | */ |
8 | 8 | public class KqTemplate { |
9 | 9 | |
10 | + private int id ; | |
10 | 11 | private String config ; |
11 | 12 | private int schoolId ; |
12 | 13 | private String type ; |
13 | 14 | |
15 | + public int getId() { | |
16 | + return id; | |
17 | + } | |
18 | + | |
19 | + public void setId(int id) { | |
20 | + this.id = id; | |
21 | + } | |
22 | + | |
14 | 23 | public String getConfig() { |
15 | 24 | return config; |
16 | 25 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/KqService.java
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/RegisterPushService.java
0 → 100644
... | ... | @@ -0,0 +1,23 @@ |
1 | +package com.sincere.smartSearch.service; | |
2 | + | |
3 | +import com.sincere.common.dto.smartCampus.BindPushDto; | |
4 | +import com.sincere.common.dto.smartCampus.ParentDto; | |
5 | + | |
6 | +import java.util.List; | |
7 | +import java.util.Map; | |
8 | + | |
9 | +/** | |
10 | + * @author chen | |
11 | + * @version 1.0 | |
12 | + * @date 2019/12/10 0010 11:17 | |
13 | + */ | |
14 | +public interface RegisterPushService { | |
15 | + | |
16 | + List<BindPushDto> selectBindPushSchool(); | |
17 | + | |
18 | + List<ParentDto> selectNotFollow(int schoolId) ; | |
19 | + | |
20 | + List<ParentDto> selectFollow(int schoolId) ; | |
21 | + | |
22 | + List<ParentDto> selectNotBind(Map<String , Integer> map); | |
23 | +} | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/KqServiceImpl.java
... | ... | @@ -46,62 +46,7 @@ public class KqServiceImpl implements KqService { |
46 | 46 | } |
47 | 47 | |
48 | 48 | @Override |
49 | - public List<CensusKqDto> selectCensusKq(KqDto kqDto) { | |
50 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
51 | - Map<String,String> map = new HashMap<>(); | |
52 | - map.put("userId",kqDto.getUserId()); | |
53 | - map.put("tableName","SZ_AttendanceRecords"+tableSuffix); | |
54 | - map.put("type",kqDto.getType()); | |
55 | - List<CensusKqDto> list = kqTemplateMapper.selectCensusKq(map); | |
56 | - for(CensusKqDto censusKqDto : list){ | |
57 | - if(Integer.valueOf(kqDto.getType()) >= 7){ | |
58 | - //出入寝 | |
59 | - int classNumber = kqTemplateMapper.selectClassChamberNumber(censusKqDto.getClassId()); | |
60 | - censusKqDto.setAllT(classNumber); | |
61 | - } | |
62 | - Map<String,String> sqlMap = new HashMap<>(); | |
63 | - sqlMap.put("templateId",kqDto.getTemplateId()); | |
64 | - sqlMap.put("classId",censusKqDto.getClassId()+""); | |
65 | - int chuqin = kqTemplateMapper.selectClassDealDateCHUQIN(sqlMap); | |
66 | - int qingjia = kqTemplateMapper.selectClassDealDateQINGJIA(sqlMap); | |
67 | - String date = DateUtils.date2String(new Date(),DateUtils.format1); | |
68 | - sqlMap.put("endTime",date+" " + kqDto.getEndTime() +":00"); | |
69 | - qingjia = qingjia + kqTemplateMapper.selectClassLeave(sqlMap); | |
70 | - censusKqDto.setKqT(censusKqDto.getKqT()+chuqin); | |
71 | - censusKqDto.setQjT(qingjia); | |
72 | - } | |
73 | - return list ; | |
74 | - } | |
75 | - | |
76 | - @Override | |
77 | - public List<CensusKqDto> selectCensusChamberKq(KqDto kqDto) { | |
78 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
79 | - Map<String,String> map = new HashMap<>(); | |
80 | - map.put("userId",kqDto.getUserId()); | |
81 | - map.put("tableName","SZ_AttendanceRecords"+tableSuffix); | |
82 | - map.put("type",kqDto.getType()); | |
83 | - List<CensusKqDto> list = new ArrayList<>(); | |
84 | - List<KqChamber> chambers = kqTemplateMapper.selectChamberName(map.get("userId")); | |
85 | - for(KqChamber chamber :chambers){ | |
86 | - CensusKqDto censusKqDto = new CensusKqDto(); | |
87 | - map.put("id",chamber.getId()+""); | |
88 | - int allKq = kqTemplateMapper.selectChamberAllKq(map); | |
89 | - int trueKq = kqTemplateMapper.selectChamberTrueKq(map); | |
90 | - censusKqDto.setClassName(chamber.getName()); | |
91 | - censusKqDto.setAllT(allKq); | |
92 | - Map<String,String> sqlMap = new HashMap<>(); | |
93 | - sqlMap.put("templateId",kqDto.getTemplateId()); | |
94 | - sqlMap.put("userId",kqDto.getUserId()); | |
95 | - sqlMap.put("id",chamber.getId()+""); | |
96 | - int chuqin = kqTemplateMapper.selectChamberDealDateCHUQIN(sqlMap); | |
97 | - int qingjia = kqTemplateMapper.selectChamberDealDateQINGJIA(sqlMap); | |
98 | - String date = DateUtils.date2String(new Date(),DateUtils.format1); | |
99 | - sqlMap.put("endTime",date+" " + kqDto.getEndTime() +":00"); | |
100 | - qingjia = qingjia + kqTemplateMapper.selectChamberLeave(sqlMap); | |
101 | - censusKqDto.setKqT(trueKq+chuqin); | |
102 | - censusKqDto.setKqT(qingjia); | |
103 | - list.add(censusKqDto); | |
104 | - } | |
105 | - return list; | |
49 | + public String selectThirdId(Map<String, String> map) { | |
50 | + return kqTemplateMapper.selectThirdId(map); | |
106 | 51 | } |
107 | 52 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/RegisterPushServiceImpl.java
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +package com.sincere.smartSearch.service.impl; | |
2 | + | |
3 | +import com.sincere.common.dto.smartCampus.BindPushDto; | |
4 | +import com.sincere.common.dto.smartCampus.ParentDto; | |
5 | +import com.sincere.smartSearch.mapper.RegisterPushMapper; | |
6 | +import com.sincere.smartSearch.service.RegisterPushService; | |
7 | +import org.springframework.beans.factory.annotation.Autowired; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +import java.util.List; | |
11 | +import java.util.Map; | |
12 | + | |
13 | +/** | |
14 | + * @author chen | |
15 | + * @version 1.0 | |
16 | + * @date 2019/12/10 0010 11:18 | |
17 | + */ | |
18 | +@Service | |
19 | +public class RegisterPushServiceImpl implements RegisterPushService { | |
20 | + | |
21 | + @Autowired | |
22 | + RegisterPushMapper registerPushMapper ; | |
23 | + | |
24 | + @Override | |
25 | + public List<BindPushDto> selectBindPushSchool() { | |
26 | + return registerPushMapper.selectBindPushSchool(); | |
27 | + } | |
28 | + | |
29 | + @Override | |
30 | + public List<ParentDto> selectNotFollow(int schoolId) { | |
31 | + return registerPushMapper.selectNotFollow(schoolId); | |
32 | + } | |
33 | + | |
34 | + @Override | |
35 | + public List<ParentDto> selectFollow(int schoolId) { | |
36 | + return registerPushMapper.selectFollow(schoolId); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public List<ParentDto> selectNotBind(Map<String, Integer> map) { | |
41 | + return registerPushMapper.selectNotBind(map); | |
42 | + } | |
43 | +} | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/KqTemplateMapper.xml
... | ... | @@ -3,13 +3,14 @@ |
3 | 3 | <mapper namespace="com.sincere.smartSearch.mapper.KqTemplateMapper"> |
4 | 4 | |
5 | 5 | <resultMap id="TemplateMap" type="com.sincere.smartSearch.model.KqTemplate"> |
6 | + <result column="Id" property="id"/> | |
6 | 7 | <result column="config" property="config"/> |
7 | 8 | <result column="SchoolId" property="schoolId"/> |
8 | 9 | <result column="type" property="type"/> |
9 | 10 | </resultMap> |
10 | 11 | |
11 | 12 | <select id="selectKqTemplate" resultMap="TemplateMap"> |
12 | - select XA_KqTemplate.config , XA_KqTemplate.SchoolId ,SZ_School.MsgTypes as type from XA_KqTemplate | |
13 | + select XA_KqTemplate.Id , XA_KqTemplate.config , XA_KqTemplate.SchoolId ,SZ_School.MsgTypes as type from XA_KqTemplate | |
13 | 14 | join SZ_School on XA_KqTemplate.SchoolId = SZ_School.school_id |
14 | 15 | where XA_KqTemplate.State = 1 and XA_KqTemplate.TType = 1 |
15 | 16 | and (SZ_School.MsgTypes like '%4%' or SZ_School.MsgTypes like '%5%') |
... | ... | @@ -22,13 +23,11 @@ |
22 | 23 | <result column="name" property="name"/> |
23 | 24 | <result column="mobile" property="mobile"/> |
24 | 25 | <result column="pass" property="pass"/> |
25 | - <result column="DingUserId" property="dingUserId"/> | |
26 | - <result column="QiYeHaoUserId" property="weChatUserId"/> | |
27 | 26 | <result column="OpenId" property="openId"/> |
28 | 27 | <result column="face" property="face"/> |
29 | 28 | </resultMap> |
30 | 29 | <select id="selectSchoolTeacher" parameterType="java.lang.Integer" resultMap="TeacherMap"> |
31 | - select distinct a.user_id,a.school_id,a.name,a.mobile,a.face,a.pass, a.OpenId,a.QiYeHaoUserId,a.DingUserId | |
30 | + select distinct a.user_id,a.school_id,a.name,a.mobile,a.face,a.pass, a.OpenId | |
32 | 31 | from SZ_V_School_Teacher a |
33 | 32 | inner join SZ_Class b on a.class_id=b.class_id and b.state=1 and b.is_finish=0 |
34 | 33 | join SZ_UserRole on a.user_id = SZ_UserRole.user_id |
... | ... | @@ -37,7 +36,7 @@ |
37 | 36 | </select> |
38 | 37 | |
39 | 38 | <select id="selectChamberTeacher" parameterType="java.lang.Integer" resultMap="TeacherMap"> |
40 | - select distinct a.user_id,a.school_id,a.name,a.mobile,a.face,a.pass, a.OpenId,a.QiYeHaoUserId,a.DingUserId | |
39 | + select distinct a.user_id,a.school_id,a.name,a.mobile,a.face,a.pass, a.OpenId | |
41 | 40 | from SS_Room join SS_RoomManager on SS_Room.Id = SS_RoomManager.RoomId |
42 | 41 | join SZ_V_School_Teacher a on a.user_id = SS_RoomManager.ManagerId |
43 | 42 | where SS_Room.SchoolId = #{schoolId} and SS_Room.Status = 1 |
... | ... | @@ -52,116 +51,8 @@ |
52 | 51 | and ApplyName = '智能校卫' |
53 | 52 | </select> |
54 | 53 | |
55 | - <select id="selectClassChamberNumber" parameterType="java.lang.Integer" resultType="java.lang.Integer"> | |
56 | - select count(0) from SZ_V_School_Student where class_id=#{classId} and student_type=2 | |
57 | - </select> | |
58 | - | |
59 | - <resultMap id="KqMap" type="com.sincere.common.dto.smartCampus.CensusKqDto"> | |
60 | - <result column="class_id" property="classId"/> | |
61 | - <result column="class_name" property="className"/> | |
62 | - <result column="allT" property="allT"/> | |
63 | - <result column="kqT" property="kqT"/> | |
64 | - </resultMap> | |
65 | - <select id="selectCensusKq" parameterType="java.util.Map" resultMap="KqMap"> | |
66 | - select distinct b.class_id , b.class_name, | |
67 | - (select count(distinct user_id) from SZ_V_School_Student x where c.class_id=x.class_id) as allT, | |
68 | - (select count(distinct customerid) from dblan27.xiaoanhxy.dbo.${tableName} y | |
69 | - where convert(varchar(10),y.intime,120)=convert(varchar(10),getdate(),120) and y.class_id=c.class_id and y.card_type=#{type}) as kqT | |
70 | - from sz_userrole c | |
71 | - inner join SZ_Class b on c.class_id=b.class_id and b.state=1 and b.is_finish=0 | |
72 | - inner join SZ_V_School_Teacher a on a.user_id=c.user_id and c.usertype=0 | |
73 | - where a.role_state=1 and a.user_id=#{userId} | |
74 | - </select> | |
75 | - | |
76 | - <select id="selectClassDealDateCHUQIN" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
77 | - select count(0) from EQ_DealData join SZ_V_School_Student on EQ_DealData.UserId = SZ_V_School_Student.user_id | |
78 | - where EQ_DealData.DealState ='出勤' | |
79 | - and EQ_DealData.TemplateId = #{templateId} and DealDate = CONVERT ( VARCHAR ( 10 ), getdate(), 120 ) | |
80 | - and SZ_V_School_Student.class_id = #{classId} | |
81 | - </select> | |
82 | 54 | |
83 | - <select id="selectClassDealDateQINGJIA" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
84 | - select count(0) from EQ_DealData join SZ_V_School_Student on EQ_DealData.UserId = SZ_V_School_Student.user_id | |
85 | - where EQ_DealData.DealState = '请假' | |
86 | - and EQ_DealData.TemplateId = #{templateId} and DealDate = CONVERT ( VARCHAR ( 10 ), getdate(), 120 ) | |
87 | - and SZ_V_School_Student.class_id = #{classId} | |
88 | - </select> | |
89 | - | |
90 | - <select id="selectClassLeave" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
91 | - select COUNT ( DISTINCT HS_LeaveExamine.StudentId ) from HS_LeaveExamine join SZ_V_School_Student on HS_LeaveExamine.StudentId = SZ_V_School_Student.student_id | |
92 | - where HS_LeaveExamine.State in (2,7,8,9,10,11) and HS_LeaveExamine.ReturnTime > #{endTime} and HS_LeaveExamine.LeaveTime < #{endTime} | |
93 | - and SZ_V_School_Student.class_id = #{classId} | |
94 | - </select> | |
95 | - | |
96 | - <resultMap id="ChamberMap" type="com.sincere.smartSearch.model.KqChamber"> | |
97 | - <result column="Id" property="id"/> | |
98 | - <result column="name" property="name"/> | |
99 | - </resultMap> | |
100 | - <select id="selectChamberName" parameterType="java.lang.String" resultMap="ChamberMap"> | |
101 | - select SS_Room.Id , SS_Room.name as name from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId | |
102 | - where SS_RoomManager.ManagerId = #{userId} | |
55 | + <select id="selectThirdId" parameterType="java.util.Map" resultType="java.lang.String"> | |
56 | + select DQuserId from EM_QyDingUser where HxyUserId = #{userId} and State = 1 and QyType = #{type} | |
103 | 57 | </select> |
104 | - | |
105 | - <select id="selectChamberAllKq" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
106 | - select count(0) as allT from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid | |
107 | - where SS_Room.Pid in ( | |
108 | - select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId | |
109 | - where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id} | |
110 | - ) and SS_RoomNumber.StudentId != 0 | |
111 | - </select> | |
112 | - | |
113 | - <select id="selectChamberTrueKq" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
114 | - SELECT COUNT ( DISTINCT customerid ) AS kqT FROM dblan27.xiaoanhxy.dbo.${tableName} y | |
115 | - WHERE CONVERT ( VARCHAR ( 10 ), y.intime, 120 ) = CONVERT ( VARCHAR ( 10 ), getdate(), 120 ) | |
116 | - AND y.card_type= #{type} | |
117 | - AND y.customerId IN ( | |
118 | - SELECT SS_RoomNumber.StudentId AS customerId | |
119 | - FROM SS_RoomNumber JOIN SS_Room ON SS_Room.Id = SS_RoomNumber.Pid | |
120 | - WHERE SS_Room.Pid IN ( | |
121 | - SELECT SS_Room.ID FROM SS_RoomManager JOIN SS_Room ON SS_Room.Id = SS_RoomManager.RoomId | |
122 | - WHERE SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id} | |
123 | - ) | |
124 | - AND SS_RoomNumber.StudentId != 0 | |
125 | - ) | |
126 | - </select> | |
127 | - | |
128 | - <select id="selectChamberDealDateCHUQIN" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
129 | - select count(0) from EQ_DealData join SZ_V_School_Student on EQ_DealData.UserId = SZ_V_School_Student.user_id | |
130 | - where EQ_DealData.DealState ='出勤' | |
131 | - and EQ_DealData.TemplateId = #{templateId} and DealDate = CONVERT ( VARCHAR ( 10 ), getdate(), 120 ) | |
132 | - and SZ_V_School_Student.student_id in ( | |
133 | - select SS_RoomNumber.StudentId from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid | |
134 | - where SS_Room.Pid in ( | |
135 | - select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId | |
136 | - where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id} | |
137 | - ) and SS_RoomNumber.StudentId != 0 | |
138 | - ) | |
139 | - </select> | |
140 | - | |
141 | - <select id="selectChamberDealDateQINGJIA" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
142 | - select count(0) from EQ_DealData join SZ_V_School_Student on EQ_DealData.UserId = SZ_V_School_Student.user_id | |
143 | - where EQ_DealData.DealState ='请假' | |
144 | - and EQ_DealData.TemplateId = #{templateId} and DealDate = CONVERT ( VARCHAR ( 10 ), getdate(), 120 ) | |
145 | - and SZ_V_School_Student.student_id in ( | |
146 | - select SS_RoomNumber.StudentId from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid | |
147 | - where SS_Room.Pid in ( | |
148 | - select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId | |
149 | - where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id} | |
150 | - ) and SS_RoomNumber.StudentId != 0 | |
151 | - ) | |
152 | - </select> | |
153 | - | |
154 | - <select id="selectChamberLeave" parameterType="java.util.Map" resultType="java.lang.Integer"> | |
155 | - select COUNT ( DISTINCT HS_LeaveExamine.StudentId ) from HS_LeaveExamine join SZ_V_School_Student on HS_LeaveExamine.StudentId = SZ_V_School_Student.student_id | |
156 | - where HS_LeaveExamine.State in (2,7,8,9,10,11) and HS_LeaveExamine.ReturnTime > #{endTime} and HS_LeaveExamine.LeaveTime < #{endTime} | |
157 | - and SZ_V_School_Student.student_id in ( | |
158 | - select SS_RoomNumber.StudentId from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid | |
159 | - where SS_Room.Pid in ( | |
160 | - select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId | |
161 | - where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id} | |
162 | - ) and SS_RoomNumber.StudentId != 0 | |
163 | - ) | |
164 | - </select> | |
165 | - | |
166 | - | |
167 | 58 | </mapper> | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/RegisterPushMapper.xml
0 → 100644
... | ... | @@ -0,0 +1,61 @@ |
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.sincere.smartSearch.mapper.RegisterPushMapper" > | |
4 | + | |
5 | + <resultMap id="BindPushDto" type="com.sincere.common.dto.smartCampus.BindPushDto" > | |
6 | + <result column="SchoolId" property="schoolId" /> | |
7 | + <result column="type" property="type" /> | |
8 | + <result column="BeginDate" property="beginDate" /> | |
9 | + <result column="EndDate" property="endDate" /> | |
10 | + <result column="IntervalDays" property="intervalDays" /> | |
11 | + <result column="PushTime" property="pushTime" /> | |
12 | + <result column="Msg" property="msg" /> | |
13 | + </resultMap> | |
14 | + | |
15 | + <select id="selectBindPushSchool" resultType="java.lang.Integer" resultMap="BindPushDto"> | |
16 | + select SchoolId , type , BeginDate , EndDate , IntervalDays. PushTime , Msg from EM_QYHID where isPush = 1 | |
17 | + </select> | |
18 | + | |
19 | + | |
20 | + <resultMap id="ParentMap" type="com.sincere.common.dto.smartCampus.ParentDto"> | |
21 | + <result column="parent_id" property="parentId"/> | |
22 | + <result column="school_id" property="schoolId"/> | |
23 | + <result column="mobile" property="mobile"/> | |
24 | + </resultMap> | |
25 | + | |
26 | + <select id="selectNotFollow" parameterType="java.lang.Integer" resultMap="ParentMap"> | |
27 | + SELECT SZ_V_School_Parent.parent_id , SZ_V_School_Parent.school_id , SZ_V_School_Parent.mobile FROM SZ_V_School_Parent WHERE not EXISTS | |
28 | + (SELECT NULL | |
29 | + FROM SZ_V_School_Student | |
30 | + WHERE SZ_V_School_Parent.class_id = SZ_V_School_Student.class_id | |
31 | + AND SZ_V_School_Parent.parent_mobile = SZ_V_School_Student.ParentMobile | |
32 | + ) | |
33 | + and school_id = #{schoolId} | |
34 | + </select> | |
35 | + | |
36 | + <select id="selectFollow" parameterType="java.lang.Integer" resultMap="ParentMap"> | |
37 | + SELECT SZ_V_School_Parent.parent_id , SZ_V_School_Parent.school_id , SZ_V_School_Parent.mobile FROM SZ_V_School_Parent WHERE EXISTS | |
38 | + (SELECT NULL | |
39 | + FROM SZ_V_School_Student | |
40 | + WHERE SZ_V_School_Parent.class_id = SZ_V_School_Student.class_id | |
41 | + AND SZ_V_School_Parent.parent_mobile = SZ_V_School_Student.ParentMobile | |
42 | + ) | |
43 | + and school_id = #{schoolId} | |
44 | + </select> | |
45 | + | |
46 | + <select id="selectNotBind" parameterType="java.util.Map" resultMap="ParentMap"> | |
47 | + SELECT SZ_V_School_Parent.parent_id , SZ_V_School_Parent.school_id , SZ_V_School_Parent.mobile FROM SZ_V_School_Parent WHERE EXISTS | |
48 | + (SELECT NULL | |
49 | + FROM SZ_V_School_Student | |
50 | + WHERE SZ_V_School_Parent.class_id = SZ_V_School_Student.class_id | |
51 | + AND SZ_V_School_Parent.parent_mobile = SZ_V_School_Student.ParentMobile | |
52 | + ) | |
53 | + and school_id = #{schoolId} | |
54 | + <if test="type == 4"> | |
55 | + and ( DingUserId is null or DingUserId = '' ) | |
56 | + </if> | |
57 | + <if test="type == 5"> | |
58 | + and ( QiYeHaoUserId is null or QiYeHaoUserId = '' ) | |
59 | + </if> | |
60 | + </select> | |
61 | +</mapper> | |
0 | 62 | \ No newline at end of file | ... | ... |
cloud/weigeng/pom.xml
... | ... | @@ -20,16 +20,16 @@ |
20 | 20 | |
21 | 21 | <dependencies> |
22 | 22 | <dependency> |
23 | + <groupId>io.netty</groupId> | |
24 | + <artifactId>netty-all</artifactId> | |
25 | + <version>4.1.33.Final</version> | |
26 | + </dependency> | |
27 | + <dependency> | |
23 | 28 | <groupId>com.sincere</groupId> |
24 | 29 | <artifactId>common</artifactId> |
25 | 30 | <version>1.0.0</version> |
26 | 31 | </dependency> |
27 | 32 | <dependency> |
28 | - <groupId>org.apache.mina</groupId> | |
29 | - <artifactId>mina-core</artifactId> | |
30 | - <version>2.1.3</version> | |
31 | - </dependency> | |
32 | - <dependency> | |
33 | 33 | <groupId>org.apache.poi</groupId> |
34 | 34 | <artifactId>poi</artifactId> |
35 | 35 | <version>4.1.0</version> | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/Watch1200.java
0 → 100644
... | ... | @@ -0,0 +1,61 @@ |
1 | +package com.sincere.weigeng; | |
2 | + | |
3 | +import com.sincere.weigeng.feign.SmFeign; | |
4 | +import com.sincere.weigeng.feign.XaFeign; | |
5 | +import com.sincere.weigeng.utils.WatchServer; | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.boot.ApplicationArguments; | |
8 | +import org.springframework.boot.ApplicationRunner; | |
9 | +import org.springframework.stereotype.Component; | |
10 | + | |
11 | +/** | |
12 | + * @author chen | |
13 | + * @version 1.0 | |
14 | + * @date 2019/12/3 0003 11:42 | |
15 | + */ | |
16 | +@Component | |
17 | +public class Watch1200 extends WatchServer implements ApplicationRunner { | |
18 | + | |
19 | + @Autowired | |
20 | + SmFeign smFeign ; | |
21 | + | |
22 | + @Autowired | |
23 | + XaFeign xaFeign; | |
24 | + | |
25 | + @Override | |
26 | + public void run(ApplicationArguments args) throws Exception { | |
27 | + watchPort(1200); | |
28 | + Listen1200 listen1200 = new Listen1200(this); | |
29 | + listen1200.start(); | |
30 | + } | |
31 | + | |
32 | + class Listen1200 extends Thread{ | |
33 | + | |
34 | + private Watch1200 watch1200 ; | |
35 | + | |
36 | + public Watch1200 getWatch1200() { | |
37 | + return watch1200; | |
38 | + } | |
39 | + | |
40 | + public void setWatch1200(Watch1200 watch1200) { | |
41 | + this.watch1200 = watch1200; | |
42 | + } | |
43 | + | |
44 | + | |
45 | + public Listen1200(Watch1200 watch1200) { | |
46 | + this.watch1200 = watch1200; | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + public synchronized void start() { | |
51 | + super.start(); | |
52 | + } | |
53 | + | |
54 | + @Override | |
55 | + public void run() { | |
56 | + super.run(); | |
57 | + this.watch1200.listen(smFeign,xaFeign); | |
58 | + } | |
59 | + } | |
60 | + | |
61 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/Watch1300.java
0 → 100644
... | ... | @@ -0,0 +1,61 @@ |
1 | +package com.sincere.weigeng; | |
2 | + | |
3 | +import com.sincere.weigeng.feign.SmFeign; | |
4 | +import com.sincere.weigeng.feign.XaFeign; | |
5 | +import com.sincere.weigeng.utils.WatchServer; | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.boot.ApplicationArguments; | |
8 | +import org.springframework.boot.ApplicationRunner; | |
9 | +import org.springframework.stereotype.Component; | |
10 | + | |
11 | +/** | |
12 | + * @author chen | |
13 | + * @version 1.0 | |
14 | + * @date 2019/12/3 0003 11:42 | |
15 | + */ | |
16 | +@Component | |
17 | +public class Watch1300 extends WatchServer implements ApplicationRunner { | |
18 | + | |
19 | + @Autowired | |
20 | + SmFeign smFeign ; | |
21 | + | |
22 | + @Autowired | |
23 | + XaFeign xaFeign; | |
24 | + | |
25 | + @Override | |
26 | + public void run(ApplicationArguments args) throws Exception { | |
27 | + watchPort(1300); | |
28 | + Listen1300 listen1300 = new Listen1300(this); | |
29 | + listen1300.start(); | |
30 | + } | |
31 | + | |
32 | + class Listen1300 extends Thread{ | |
33 | + | |
34 | + private Watch1300 watch1300 ; | |
35 | + | |
36 | + public Watch1300 getWatch1300() { | |
37 | + return watch1300; | |
38 | + } | |
39 | + | |
40 | + public void setWatch1300(Watch1300 watch1300) { | |
41 | + this.watch1300 = watch1300; | |
42 | + } | |
43 | + | |
44 | + | |
45 | + public Listen1300(Watch1300 watch1300) { | |
46 | + this.watch1300 = watch1300; | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + public synchronized void start() { | |
51 | + super.start(); | |
52 | + } | |
53 | + | |
54 | + @Override | |
55 | + public void run() { | |
56 | + super.run(); | |
57 | + this.watch1300.listen(smFeign,xaFeign); | |
58 | + } | |
59 | + } | |
60 | + | |
61 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/WeigengApplication.java
1 | 1 | package com.sincere.weigeng; |
2 | 2 | |
3 | -import com.sincere.weigeng.utils.WatchServer; | |
4 | 3 | import org.springframework.boot.SpringApplication; |
5 | 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
6 | 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; |
... | ... | @@ -11,12 +10,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients; |
11 | 10 | @SpringBootApplication |
12 | 11 | public class WeigengApplication { |
13 | 12 | |
14 | - private static String ip = "172.16.3.175"; | |
15 | - private static int port = 1200; | |
16 | - | |
17 | 13 | public static void main(String[] args) { |
18 | 14 | SpringApplication.run(WeigengApplication.class, args); |
19 | - //WatchServer.WatchingServerRunning(ip,port); | |
20 | 15 | } |
21 | 16 | |
22 | 17 | } | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/controller/WgController.java
... | ... | @@ -7,12 +7,16 @@ import com.sincere.common.dto.smartCampus.UserDto; |
7 | 7 | import com.sincere.common.dto.xiaoan.SendFailDto; |
8 | 8 | import com.sincere.common.dto.xiaoan.SendMessageDto; |
9 | 9 | import com.sincere.common.dto.xiaoan.SendSuccessDto; |
10 | +import com.sincere.weigeng.Watch1200; | |
11 | +import com.sincere.weigeng.Watch1300; | |
10 | 12 | import com.sincere.weigeng.feign.SmFeign; |
11 | 13 | import com.sincere.weigeng.feign.XaFeign; |
12 | 14 | import com.sincere.weigeng.logs.LogName; |
13 | 15 | import com.sincere.weigeng.logs.LoggerUtils; |
14 | 16 | import com.sincere.weigeng.utils.WatchServer; |
15 | 17 | import com.sincere.weigeng.vo.*; |
18 | +import io.netty.channel.ChannelHandlerContext; | |
19 | +import io.netty.channel.socket.DatagramPacket; | |
16 | 20 | import io.swagger.annotations.Api; |
17 | 21 | import io.swagger.annotations.ApiOperation; |
18 | 22 | import org.slf4j.Logger; |
... | ... | @@ -42,39 +46,76 @@ public class WgController { |
42 | 46 | @Autowired |
43 | 47 | XaFeign xaFeign; |
44 | 48 | |
45 | - private static String ip = "172.16.3.175"; | |
46 | - private static int port = 1200; | |
49 | + @Autowired | |
50 | + Watch1200 watch1200 ; | |
51 | + | |
52 | + @Autowired | |
53 | + Watch1300 watch1300 ; | |
47 | 54 | |
48 | - @RequestMapping(value = "watching" , method = RequestMethod.GET) | |
49 | - public void watching(){ | |
50 | - WatchServer.WatchingServerRunning(ip,port,smFeign,xaFeign); | |
55 | + public ChannelHandlerContext getContext(long sno){ | |
56 | + ChannelHandlerContext context1200 = watch1200.getContext(sno) ; | |
57 | + ChannelHandlerContext context1300 = watch1300.getContext(sno) ; | |
58 | + if(context1200 == null){ | |
59 | + return context1300; | |
60 | + }else { | |
61 | + return context1200 ; | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + public DatagramPacket getPacket(long sno){ | |
66 | + DatagramPacket packet1200 = watch1200.getPacket(sno); | |
67 | + DatagramPacket packet1300 = watch1300.getPacket(sno); | |
68 | + if(packet1200 == null){ | |
69 | + return packet1300 ; | |
70 | + }else { | |
71 | + return packet1200 ; | |
72 | + } | |
73 | + } | |
74 | + | |
75 | + @RequestMapping(value = "openDoor1" , method = RequestMethod.GET) | |
76 | + public void openDoor1(){ | |
77 | + OpenDoorVo openDoorVo = new OpenDoorVo(); | |
78 | + openDoorVo.setId(1); | |
79 | + openDoorVo.setSn(253163272); | |
80 | + openDoorVo.setType(1); | |
81 | + openDoorVo.setDoorNo(1); | |
82 | + this.openDoor(openDoorVo); | |
83 | + } | |
84 | + | |
85 | + @RequestMapping(value = "openDoor2" , method = RequestMethod.GET) | |
86 | + public void openDoor2(){ | |
87 | + OpenDoorVo openDoorVo = new OpenDoorVo(); | |
88 | + openDoorVo.setId(1); | |
89 | + openDoorVo.setSn(253160793); | |
90 | + openDoorVo.setType(1); | |
91 | + openDoorVo.setDoorNo(1); | |
92 | + this.openDoor(openDoorVo); | |
51 | 93 | } |
52 | 94 | |
53 | 95 | @RequestMapping(value = "setTime" , method = RequestMethod.GET) |
54 | 96 | public void setTime(long sn){ |
55 | - WatchServer.setTime(xaFeign,sn,"48"); | |
97 | + WatchServer.setTime(xaFeign,getContext(sn),getPacket(sn),sn,"48"); | |
56 | 98 | } |
57 | 99 | |
58 | 100 | @ApiOperation("远程开门") |
59 | 101 | @RequestMapping(value = "openDoor" , method = RequestMethod.POST) |
60 | 102 | public boolean openDoor(@RequestBody OpenDoorVo openDoorVo) { |
61 | 103 | String functionId = smFeign.selectOutOrderId(openDoorVo.getType(),openDoorVo.getId()); |
62 | - long messageId = WatchServer.openDoor(xaFeign,openDoorVo.getSn(),functionId,openDoorVo.getDoorNo(),null); | |
104 | + long messageId = WatchServer.openDoor(xaFeign,getContext(openDoorVo.getSn()),getPacket(openDoorVo.getSn()),openDoorVo.getSn(),functionId,openDoorVo.getDoorNo(),null); | |
63 | 105 | SendMessageDto message = getResult(messageId); |
64 | 106 | if(message.getCorrect() == 1){ |
65 | - Log_orderSuccess.info("web端远程开门成功!"); | |
107 | + Log_orderSuccess.info("web端远程开门成功!") ; | |
66 | 108 | }else { |
67 | - Log_orderFail.info("远程开门失败"); | |
109 | + Log_orderFail.info("远程开门失败") ; | |
68 | 110 | } |
69 | 111 | return message.getCorrect() == 1 ; |
70 | 112 | } |
71 | 113 | |
72 | - | |
73 | 114 | @ApiOperation("设置考勤时段") |
74 | 115 | @RequestMapping(value = "setAttendanceTime" , method = RequestMethod.POST) |
75 | 116 | public boolean setAttendanceTime(@RequestBody AttendanceTimeVo attendanceTimeVo){ |
76 | 117 | String functionId = smFeign.selectOutOrderId(attendanceTimeVo.getType(),attendanceTimeVo.getId()); |
77 | - List<Long> result = WatchServer.SetAttendanceTime(xaFeign,attendanceTimeVo.getSn(),functionId,attendanceTimeVo.getShiduan(), | |
118 | + List<Long> result = WatchServer.SetAttendanceTime(xaFeign,getContext(attendanceTimeVo.getSn()),getPacket(attendanceTimeVo.getSn()),attendanceTimeVo.getSn(),functionId,attendanceTimeVo.getShiduan(), | |
78 | 119 | attendanceTimeVo.getStart(),attendanceTimeVo.getEnd(),attendanceTimeVo.getIsMonday(),attendanceTimeVo.getIsTuesday(), |
79 | 120 | attendanceTimeVo.getIsWednesday(),attendanceTimeVo.getIsThursday(),attendanceTimeVo.getIsFriday(), |
80 | 121 | attendanceTimeVo.getIsSaturday(),attendanceTimeVo.getIsWeekend(),attendanceTimeVo.getShiqu()); |
... | ... | @@ -91,13 +132,12 @@ public class WgController { |
91 | 132 | return isSuccess; |
92 | 133 | } |
93 | 134 | |
94 | - | |
95 | 135 | @ApiOperation("单个卡号的权限添加或修改") |
96 | 136 | @RequestMapping(value = "setSignalCardInfo" , method = RequestMethod.POST) |
97 | 137 | public boolean setSignalCardInfo(@RequestBody SignalCardInfoVo signalCardInfoVo){ |
98 | 138 | String functionId = smFeign.selectOutOrderId(signalCardInfoVo.getType(),signalCardInfoVo.getId()); |
99 | 139 | String cardNo = initCardNo(signalCardInfoVo.getCardNo()); |
100 | - long messageId = WatchServer.SetSignalCardInfo(xaFeign,signalCardInfoVo.getSn(),functionId,cardNo, | |
140 | + long messageId = WatchServer.SetSignalCardInfo(xaFeign,getContext(signalCardInfoVo.getSn()),getPacket(signalCardInfoVo.getSn()),signalCardInfoVo.getSn(),functionId,cardNo, | |
101 | 141 | signalCardInfoVo.getShiduan(),signalCardInfoVo.getStartTime(),signalCardInfoVo.getEndTime()); |
102 | 142 | SendMessageDto message = getResult(messageId); |
103 | 143 | UserDto user = smFeign.selectUserByCardNum(cardNo); |
... | ... | @@ -136,7 +176,7 @@ public class WgController { |
136 | 176 | public boolean clearSinglePower(@RequestBody CardInfo cardInfo){ |
137 | 177 | String functionId = smFeign.selectOutOrderId(cardInfo.getType(),cardInfo.getId()); |
138 | 178 | String cardNo = initCardNo(cardInfo.getCardNo()); |
139 | - long messageId = WatchServer.clearSinglePower(xaFeign,cardInfo.getSn(),functionId,cardNo); | |
179 | + long messageId = WatchServer.clearSinglePower(xaFeign,getContext(cardInfo.getSn()),getPacket(cardInfo.getSn()),cardInfo.getSn(),functionId,cardNo); | |
140 | 180 | SendMessageDto message = getResult(messageId); |
141 | 181 | if(message.getCorrect() == 1){ |
142 | 182 | Log_orderSuccess.info("卡号"+cardNo+"清除权限成功"); |
... | ... | @@ -154,7 +194,7 @@ public class WgController { |
154 | 194 | @RequestMapping(value = "clearAllPower" , method = RequestMethod.POST) |
155 | 195 | public boolean clearAllPower(@RequestBody CleanShiDuanVo cleanShiDuanVo){ |
156 | 196 | String functionId = smFeign.selectOutOrderId(cleanShiDuanVo.getType(),cleanShiDuanVo.getId()); |
157 | - long messageId = WatchServer.clearAllPower(xaFeign,cleanShiDuanVo.getSn(),functionId); | |
197 | + long messageId = WatchServer.clearAllPower(xaFeign,getContext(cleanShiDuanVo.getSn()),getPacket(cleanShiDuanVo.getSn()),cleanShiDuanVo.getSn(),functionId); | |
158 | 198 | SendMessageDto message = getResult(messageId); |
159 | 199 | if(message.getCorrect() == 1){ |
160 | 200 | Log_orderSuccess.info("设备"+cleanShiDuanVo.getSn()+"清除权限成功"); |
... | ... | @@ -172,7 +212,7 @@ public class WgController { |
172 | 212 | @RequestMapping(value = "clearShiDuan" , method = RequestMethod.POST) |
173 | 213 | public boolean clearShiDuan(@RequestBody CleanShiDuanVo cleanShiDuanVo){ |
174 | 214 | String functionId = smFeign.selectOutOrderId(cleanShiDuanVo.getType(),cleanShiDuanVo.getId()); |
175 | - long messageId = WatchServer.clearShiDuan(xaFeign,cleanShiDuanVo.getSn(),functionId); | |
215 | + long messageId = WatchServer.clearShiDuan(xaFeign,getContext(cleanShiDuanVo.getSn()),getPacket(cleanShiDuanVo.getSn()),cleanShiDuanVo.getSn(),functionId); | |
176 | 216 | SendMessageDto sendMessage = getResult(messageId); |
177 | 217 | if(sendMessage.getCorrect() == 1){ |
178 | 218 | Log_orderSuccess.info("设备"+cleanShiDuanVo.getSn()+"时段清除成功"); |
... | ... | @@ -187,7 +227,7 @@ public class WgController { |
187 | 227 | public boolean searchPower(@RequestBody CardInfo cardInfo){ |
188 | 228 | String functionId = smFeign.selectOutOrderId(cardInfo.getType(),cardInfo.getId()); |
189 | 229 | String cardNo = initCardNo(cardInfo.getCardNo()); |
190 | - long messageId = WatchServer.searchPower(xaFeign,cardInfo.getSn(),functionId,cardNo); | |
230 | + long messageId = WatchServer.searchPower(xaFeign,getContext(cardInfo.getSn()),getPacket(cardInfo.getSn()),cardInfo.getSn(),functionId,cardNo); | |
191 | 231 | SendMessageDto sendMessage = getResult(messageId); |
192 | 232 | if(sendMessage.getCorrect() == 1){ |
193 | 233 | Log_orderSuccess.info("设备"+cardInfo.getSn()+"卡号"+cardNo+"查询权限成功"); | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/UdpServerHandler.java
0 → 100644
... | ... | @@ -0,0 +1,68 @@ |
1 | +package com.sincere.weigeng.utils; | |
2 | + | |
3 | +import com.sincere.common.util.DateUtils; | |
4 | +import com.sincere.weigeng.logs.LogName; | |
5 | +import com.sincere.weigeng.logs.LoggerUtils; | |
6 | +import io.netty.buffer.ByteBuf; | |
7 | +import io.netty.channel.ChannelHandlerContext; | |
8 | +import io.netty.channel.SimpleChannelInboundHandler; | |
9 | +import io.netty.channel.socket.DatagramPacket; | |
10 | +import io.netty.util.ReferenceCountUtil; | |
11 | +import org.slf4j.Logger; | |
12 | + | |
13 | +import java.util.Date; | |
14 | +import java.util.Map; | |
15 | +import java.util.Queue; | |
16 | + | |
17 | +/** | |
18 | + * @author chen | |
19 | + * @version 1.0 | |
20 | + * @date 2019/11/21 0021 9:18 | |
21 | + */ | |
22 | +public class UdpServerHandler extends SimpleChannelInboundHandler<DatagramPacket> { | |
23 | + | |
24 | + private static Logger Log_error = LoggerUtils.Logger(LogName.error); | |
25 | + private static Logger Log_heartBeat = LoggerUtils.Logger(LogName.heartBeat); | |
26 | + | |
27 | + private String dateTime = "" ; | |
28 | + private int i = 0 ; | |
29 | + | |
30 | + private Queue<byte[]> queue; | |
31 | + private Map<Long , ChannelHandlerContext> channelMap ; | |
32 | + private Map<Long , DatagramPacket> packetMap ; | |
33 | + | |
34 | + public UdpServerHandler(Queue<byte[]> queue , Map<Long , ChannelHandlerContext> channelMap , Map<Long , DatagramPacket> packetMap) { | |
35 | + super(); | |
36 | + this.queue = queue; | |
37 | + this.channelMap = channelMap; | |
38 | + this.packetMap = packetMap ; | |
39 | + } | |
40 | + | |
41 | + | |
42 | + @Override | |
43 | + protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet){ | |
44 | + try{ | |
45 | + i++ ; | |
46 | + String time = DateUtils.date2String(new Date() , DateUtils.format3); | |
47 | + if(!dateTime.equals(time)){ | |
48 | + Log_heartBeat.info("------------------------"+packet.recipient().getPort()+"访问次数" + i); | |
49 | + dateTime = time ; | |
50 | + i = 1 ; | |
51 | + } | |
52 | + ByteBuf buf = packet.copy().content(); | |
53 | + byte[] validBytes = new byte[buf.readableBytes()]; | |
54 | + buf.readBytes(validBytes); | |
55 | + if (validBytes.length == WgUdpCommShort.WGPacketSize) { | |
56 | + synchronized (queue) { | |
57 | + long sn = WgUdpCommShort.getLongByByte(validBytes, 4, 4); | |
58 | + channelMap.put(sn,ctx); | |
59 | + packetMap.put(sn,packet); | |
60 | + queue.offer(validBytes); | |
61 | + } | |
62 | + } | |
63 | + ReferenceCountUtil.release(buf); | |
64 | + }catch (Exception e){ | |
65 | + Log_error.info(e.toString()); | |
66 | + } | |
67 | + } | |
68 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WatchServer.java
1 | 1 | package com.sincere.weigeng.utils; |
2 | 2 | |
3 | - | |
4 | 3 | import com.sincere.common.dto.smartCampus.UserDto; |
5 | 4 | import com.sincere.common.dto.xiaoan.CheckInDto; |
6 | 5 | import com.sincere.common.dto.xiaoan.CheckOutDto; |
... | ... | @@ -11,14 +10,16 @@ import com.sincere.weigeng.feign.SmFeign; |
11 | 10 | import com.sincere.weigeng.feign.XaFeign; |
12 | 11 | import com.sincere.weigeng.logs.LogName; |
13 | 12 | import com.sincere.weigeng.logs.LoggerUtils; |
13 | +import io.netty.bootstrap.Bootstrap; | |
14 | +import io.netty.channel.ChannelHandlerContext; | |
15 | +import io.netty.channel.ChannelOption; | |
16 | +import io.netty.channel.EventLoopGroup; | |
17 | +import io.netty.channel.nio.NioEventLoopGroup; | |
18 | +import io.netty.channel.socket.DatagramPacket; | |
19 | +import io.netty.channel.socket.nio.NioDatagramChannel; | |
14 | 20 | import org.apache.commons.lang3.StringUtils; |
15 | -import org.apache.mina.core.session.IoSession; | |
16 | -import org.apache.mina.transport.socket.DatagramSessionConfig; | |
17 | -import org.apache.mina.transport.socket.nio.NioDatagramAcceptor; | |
18 | 21 | import org.slf4j.Logger; |
19 | 22 | |
20 | -import java.io.IOException; | |
21 | -import java.net.InetSocketAddress; | |
22 | 23 | import java.util.*; |
23 | 24 | import java.util.concurrent.ConcurrentHashMap; |
24 | 25 | |
... | ... | @@ -29,39 +30,36 @@ import java.util.concurrent.ConcurrentHashMap; |
29 | 30 | */ |
30 | 31 | public class WatchServer { |
31 | 32 | |
32 | - private static final Logger Log_orderSuccess = LoggerUtils.Logger(LogName.orderSuccess); | |
33 | - private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); | |
34 | - private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); | |
35 | - private static final Logger Log_heartBeat = LoggerUtils.Logger(LogName.heartBeat); | |
36 | - private static final Logger Log_error = LoggerUtils.Logger(LogName.error); | |
37 | - | |
38 | - private static List<Long> snoList = new ArrayList<>(); | |
39 | - private static List<Long> indexList = new ArrayList<>(); | |
40 | - private static WatchingShortHandler watchingShortHandler ; | |
41 | - private static Queue<byte[]> queue = new LinkedList<>(); | |
42 | - private static Map<Long , IoSession> sessionMap = new ConcurrentHashMap<>(); | |
43 | - | |
44 | - // 进入服务器监控状态 | |
45 | - public static int WatchingServerRunning(String watchServerIP,int watchServerPort, | |
46 | - SmFeign smFeign ,XaFeign xaFeign) { | |
47 | - watchingShortHandler = new WatchingShortHandler(queue,sessionMap); | |
48 | - // 创建UDP数据包NIO | |
49 | - NioDatagramAcceptor acceptor = new NioDatagramAcceptor(); | |
50 | - // NIO设置底层IOHandler | |
51 | - acceptor.setHandler(watchingShortHandler); | |
52 | - | |
53 | - // 设置是否重用地址? 也就是每个发过来的udp信息都是一个地址? | |
54 | - DatagramSessionConfig dcfg = acceptor.getSessionConfig(); | |
55 | - dcfg.setReuseAddress(false); | |
56 | - // 绑定端口地址 | |
33 | + private static Logger Log_error = LoggerUtils.Logger(LogName.error); | |
34 | + private static Logger Log_orderSuccess = LoggerUtils.Logger(LogName.orderSuccess); | |
35 | + private static Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); | |
36 | + private static Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); | |
37 | + private static Logger Log_heartBeat = LoggerUtils.Logger(LogName.heartBeat); | |
38 | + | |
39 | + private List<Long> snoList = new ArrayList<>(); | |
40 | + private List<Long> indexList = new ArrayList<>(); | |
41 | + private Queue<byte[]> queue = new LinkedList<>(); | |
42 | + private Map<Long , ChannelHandlerContext> channelMap = new ConcurrentHashMap<>() ; | |
43 | + private Map<Long , DatagramPacket> packetMap = new ConcurrentHashMap<>(); | |
44 | + | |
45 | + public void watchPort(int port){ | |
57 | 46 | try { |
58 | - acceptor.bind(new InetSocketAddress(watchServerIP, watchServerPort)); | |
59 | - } catch (IOException e) { | |
47 | + Bootstrap b = new Bootstrap(); | |
48 | + EventLoopGroup group = new NioEventLoopGroup(); | |
49 | + b.group(group) | |
50 | + .channel(NioDatagramChannel.class) | |
51 | + .option(ChannelOption.SO_BROADCAST, true) | |
52 | + .handler(new UdpServerHandler(queue,channelMap,packetMap)); | |
53 | + | |
54 | + b.bind(port).sync().channel(); | |
55 | + } catch (InterruptedException e) { | |
60 | 56 | Log_orderSuccess.info("绑定接收服务器失败...."); |
61 | 57 | e.printStackTrace(); |
62 | - return 0; | |
63 | 58 | } |
64 | - Log_orderSuccess.info("绑定接收服务器成功...."); | |
59 | + Log_orderSuccess.info("绑定接收服务器成功....:"+port); | |
60 | + } | |
61 | + | |
62 | + public void listen(SmFeign smFeign, XaFeign xaFeign){ | |
65 | 63 | long recordIndex = 0; |
66 | 64 | while(true) { |
67 | 65 | if (!queue.isEmpty()) { |
... | ... | @@ -69,30 +67,34 @@ public class WatchServer { |
69 | 67 | synchronized (queue) { |
70 | 68 | recvBuff= queue.poll(); |
71 | 69 | } |
72 | - if (recvBuff[1]== 0x20) { | |
73 | - long sn = WgUdpCommShort.getLongByByte(recvBuff, 4, 4); | |
74 | - smFeign.updateLinkTime(sn+""); | |
75 | - Log_heartBeat.info("设备"+sn); | |
76 | - boolean isExist = true ; | |
77 | - long recordIndexGet = WgUdpCommShort.getLongByByte(recvBuff, 8, 4); | |
78 | - if(snoList.indexOf(sn) >= 0){ | |
79 | - int number = snoList.indexOf(sn); | |
80 | - recordIndex = indexList.get(number); | |
81 | - indexList.set(number,recordIndexGet); | |
82 | - }else { | |
83 | - snoList.add(sn); | |
84 | - recordIndex = 0 ; | |
85 | - indexList.add(recordIndexGet); | |
86 | - System.out.println("设备"+sn+"上线"); | |
87 | - isExist = false ; | |
88 | - } | |
89 | - if(isExist){ | |
90 | - if (recordIndex < recordIndexGet || (recordIndexGet - recordIndex) < -5) { | |
91 | - watching(recvBuff,smFeign,xaFeign); | |
70 | + try { | |
71 | + if (recvBuff[1]== 0x20) { | |
72 | + long sn = WgUdpCommShort.getLongByByte(recvBuff, 4, 4); | |
73 | + smFeign.updateLinkTime(sn+""); | |
74 | + Log_heartBeat.info("设备"+sn); | |
75 | + boolean isExist = true ; | |
76 | + long recordIndexGet = WgUdpCommShort.getLongByByte(recvBuff, 8, 4); | |
77 | + if(snoList.indexOf(sn) >= 0){ | |
78 | + int number = snoList.indexOf(sn); | |
79 | + recordIndex = indexList.get(number); | |
80 | + indexList.set(number,recordIndexGet); | |
81 | + }else { | |
82 | + snoList.add(sn); | |
83 | + recordIndex = 0 ; | |
84 | + indexList.add(recordIndexGet); | |
85 | + System.out.println("设备"+sn+"上线"); | |
86 | + isExist = false ; | |
87 | + } | |
88 | + if(isExist){ | |
89 | + if (recordIndex < recordIndexGet || (recordIndexGet - recordIndex) < -5) { | |
90 | + watching(recvBuff,xaFeign,smFeign); | |
91 | + } | |
92 | 92 | } |
93 | + }else { | |
94 | + push(recvBuff,xaFeign); | |
93 | 95 | } |
94 | - }else { | |
95 | - push(recvBuff,xaFeign); | |
96 | + }catch (Exception e){ | |
97 | + | |
96 | 98 | } |
97 | 99 | } else { |
98 | 100 | long times = 100; |
... | ... | @@ -105,7 +107,7 @@ public class WatchServer { |
105 | 107 | } |
106 | 108 | } |
107 | 109 | |
108 | - private static void watching(byte[] recv,SmFeign smFeign ,XaFeign xaFeign){ | |
110 | + private void watching(byte[] recv , XaFeign xaFeign , SmFeign smFeign){ | |
109 | 111 | long res = 0; |
110 | 112 | //8-11 记录的索引号 |
111 | 113 | //(=0表示没有记录) 4 0x00000000 |
... | ... | @@ -177,7 +179,7 @@ public class WatchServer { |
177 | 179 | if (StringUtils.isNotBlank(studentNum)) { |
178 | 180 | int outOf = recordDoorNO == 1 ? 1 : 0; |
179 | 181 | //远程开门 |
180 | - openDoor(xaFeign,sno,"64",recordDoorNO,cardNo); | |
182 | + WatchServer.openDoor(xaFeign,channelMap.get(sno),packetMap.get(sno),sno,"64",recordDoorNO,cardNo); | |
181 | 183 | Log_orderSuccess.info("请假开门成功"+cardNo); |
182 | 184 | } else { |
183 | 185 | //没有请假不做任何处理,则是刷卡异常,入库 |
... | ... | @@ -196,7 +198,7 @@ public class WatchServer { |
196 | 198 | } |
197 | 199 | } |
198 | 200 | |
199 | - private static void push(byte[] recv,XaFeign xaFeign){ | |
201 | + private void push(byte[] recv , XaFeign xaFeign){ | |
200 | 202 | long index = WgUdpCommShort.getXidOfCommand(recv); |
201 | 203 | long sno = WgUdpCommShort.getLongByByte(recv, 4, 4); |
202 | 204 | String functionId = WGUtils.byte2Hex(recv[1]); |
... | ... | @@ -216,8 +218,17 @@ public class WatchServer { |
216 | 218 | } |
217 | 219 | } |
218 | 220 | |
221 | + public ChannelHandlerContext getContext(long sno){ | |
222 | + return channelMap.get(sno) ; | |
223 | + } | |
224 | + | |
225 | + public DatagramPacket getPacket(long sno){ | |
226 | + return packetMap.get(sno); | |
227 | + } | |
228 | + | |
219 | 229 | //远程开门 |
220 | - public static long openDoor(XaFeign xaFeign,long sno , String outsideOrderId,int doorNo , String cardNo){ | |
230 | + public static long openDoor(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , | |
231 | + long sno , String outsideOrderId, int doorNo , String cardNo){ | |
221 | 232 | WgUdpCommShort pkt = new WgUdpCommShort(); |
222 | 233 | pkt.iDevSn = sno; |
223 | 234 | try{ |
... | ... | @@ -234,7 +245,7 @@ public class WatchServer { |
234 | 245 | byte[] bytes = pkt.toByte(); |
235 | 246 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
236 | 247 | long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); |
237 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
248 | + pkt.run(context,packet,bytes); | |
238 | 249 | return result ; |
239 | 250 | }catch (Exception e){ |
240 | 251 | Log_error.error(e.toString()); |
... | ... | @@ -243,7 +254,7 @@ public class WatchServer { |
243 | 254 | } |
244 | 255 | |
245 | 256 | //重置控制板时间 |
246 | - public static long setTime(XaFeign xaFeign,long sno , String outsideOrderId){ | |
257 | + public static long setTime(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno , String outsideOrderId){ | |
247 | 258 | WgUdpCommShort pkt = new WgUdpCommShort(); |
248 | 259 | pkt.iDevSn = sno; |
249 | 260 | try{ |
... | ... | @@ -253,14 +264,14 @@ public class WatchServer { |
253 | 264 | pkt.data[0] = WGUtils.toHex(String.valueOf(cal.get(Calendar.YEAR)).substring(0,2)); |
254 | 265 | pkt.data[1] = WGUtils.toHex(String.valueOf(cal.get(Calendar.YEAR)).substring(2,4)); |
255 | 266 | pkt.data[2] = WGUtils.toHex(String.valueOf(cal.get(Calendar.MONTH)+1)); |
256 | - pkt.data[3] = WGUtils.toHex(String.valueOf(cal.get(Calendar.DATE))); | |
267 | + pkt.data[3] = WGUtils.toHex(String.valueOf(cal.get(Calendar.DATE)-1)); | |
257 | 268 | pkt.data[4] =WGUtils.toHex(String.valueOf(cal.get(Calendar.HOUR_OF_DAY))); |
258 | 269 | pkt.data[5] =WGUtils.toHex(String.valueOf(cal.get(Calendar.MINUTE))); |
259 | 270 | pkt.data[6] = WGUtils.toHex(String.valueOf(cal.get(Calendar.SECOND))); |
260 | 271 | byte[] bytes = pkt.toByte(); |
261 | 272 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
262 | 273 | long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); |
263 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
274 | + pkt.run(context,packet,bytes); | |
264 | 275 | return result ; |
265 | 276 | }catch (Exception e){ |
266 | 277 | Log_error.error(e.toString()); |
... | ... | @@ -269,11 +280,10 @@ public class WatchServer { |
269 | 280 | } |
270 | 281 | |
271 | 282 | |
272 | - | |
273 | 283 | //设置考勤时段 |
274 | - public static List<Long> SetAttendanceTime(XaFeign xaFeign,long sno ,String outsideOrderId, int shiduan , Date begin ,Date end , | |
275 | - int isMonDay ,int isTuesDay , int isWednesDay ,int isThursDay , int isFriday , | |
276 | - int isSaturDay , int isWeekend , String shiqu){ | |
284 | + public static List<Long> SetAttendanceTime(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno ,String outsideOrderId, int shiduan , Date begin ,Date end , | |
285 | + int isMonDay ,int isTuesDay , int isWednesDay ,int isThursDay , int isFriday , | |
286 | + int isSaturDay , int isWeekend , String shiqu){ | |
277 | 287 | List<Long> resultList = new ArrayList<>(); |
278 | 288 | WgUdpCommShort pkt = new WgUdpCommShort(); |
279 | 289 | pkt.iDevSn = sno; |
... | ... | @@ -341,7 +351,7 @@ public class WatchServer { |
341 | 351 | byte[] bytes = pkt.toByte(); |
342 | 352 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
343 | 353 | long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); |
344 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
354 | + pkt.run(context,packet,bytes); | |
345 | 355 | resultList.add(result); |
346 | 356 | } |
347 | 357 | return resultList ; |
... | ... | @@ -351,9 +361,8 @@ public class WatchServer { |
351 | 361 | return resultList; |
352 | 362 | } |
353 | 363 | |
354 | - | |
355 | 364 | //设置权限 |
356 | - public static long SetSignalCardInfo(XaFeign xaFeign,long sno , String outsideOrderId, String cardNo , int shiduan , Date begin , Date end){ | |
365 | + public static long SetSignalCardInfo(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno , String outsideOrderId, String cardNo , int shiduan , Date begin , Date end){ | |
357 | 366 | WgUdpCommShort pkt = new WgUdpCommShort(); |
358 | 367 | pkt.iDevSn = sno; |
359 | 368 | try{ |
... | ... | @@ -390,7 +399,7 @@ public class WatchServer { |
390 | 399 | byte[] bytes = pkt.toByte(); |
391 | 400 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
392 | 401 | long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); |
393 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
402 | + pkt.run(context,packet,bytes); | |
394 | 403 | return result ; |
395 | 404 | }catch (Exception e){ |
396 | 405 | Log_error.error(e.toString()); |
... | ... | @@ -399,7 +408,7 @@ public class WatchServer { |
399 | 408 | } |
400 | 409 | |
401 | 410 | //删除单张卡权限 |
402 | - public static long clearSinglePower(XaFeign xaFeign,long sno ,String outsideOrderId, String cardNo){ | |
411 | + public static long clearSinglePower(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno ,String outsideOrderId, String cardNo){ | |
403 | 412 | WgUdpCommShort pkt = new WgUdpCommShort(); |
404 | 413 | pkt.iDevSn = sno; |
405 | 414 | try{ |
... | ... | @@ -413,7 +422,7 @@ public class WatchServer { |
413 | 422 | byte[] bytes = pkt.toByte(); |
414 | 423 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
415 | 424 | long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); |
416 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
425 | + pkt.run(context,packet,bytes); | |
417 | 426 | return result ; |
418 | 427 | }catch (Exception e){ |
419 | 428 | Log_error.error(e.toString()); |
... | ... | @@ -422,7 +431,7 @@ public class WatchServer { |
422 | 431 | } |
423 | 432 | |
424 | 433 | //删除全部权限 |
425 | - public static long clearAllPower(XaFeign xaFeign,long sno ,String outsideOrderId){ | |
434 | + public static long clearAllPower(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno ,String outsideOrderId){ | |
426 | 435 | WgUdpCommShort pkt = new WgUdpCommShort(); |
427 | 436 | pkt.iDevSn = sno; |
428 | 437 | try{ |
... | ... | @@ -436,7 +445,7 @@ public class WatchServer { |
436 | 445 | byte[] bytes = pkt.toByte(); |
437 | 446 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
438 | 447 | long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); |
439 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
448 | + pkt.run(context,packet,bytes); | |
440 | 449 | return result ; |
441 | 450 | }catch (Exception e){ |
442 | 451 | Log_error.error(e.toString()); |
... | ... | @@ -445,7 +454,7 @@ public class WatchServer { |
445 | 454 | } |
446 | 455 | |
447 | 456 | //查询卡权限 |
448 | - public static long searchPower(XaFeign xaFeign,long sno ,String outsideOrderId, String cardNo){ | |
457 | + public static long searchPower(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno ,String outsideOrderId, String cardNo){ | |
449 | 458 | WgUdpCommShort pkt = new WgUdpCommShort(); |
450 | 459 | pkt.iDevSn = sno; |
451 | 460 | try{ |
... | ... | @@ -459,7 +468,7 @@ public class WatchServer { |
459 | 468 | byte[] bytes = pkt.toByte(); |
460 | 469 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
461 | 470 | long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); |
462 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
471 | + pkt.run(context,packet,bytes); | |
463 | 472 | return result ; |
464 | 473 | }catch (Exception e){ |
465 | 474 | Log_error.error(e.toString()); |
... | ... | @@ -468,7 +477,7 @@ public class WatchServer { |
468 | 477 | } |
469 | 478 | |
470 | 479 | //删除时段 |
471 | - public static long clearShiDuan(XaFeign xaFeign,long sno , String outsideOrderId){ | |
480 | + public static long clearShiDuan(XaFeign xaFeign , ChannelHandlerContext context , DatagramPacket packet , long sno , String outsideOrderId){ | |
472 | 481 | WgUdpCommShort pkt = new WgUdpCommShort(); |
473 | 482 | pkt.iDevSn = sno; |
474 | 483 | try{ |
... | ... | @@ -482,7 +491,7 @@ public class WatchServer { |
482 | 491 | byte[] bytes = pkt.toByte(); |
483 | 492 | long index = WgUdpCommShort.getXidOfCommand(bytes); |
484 | 493 | long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); |
485 | - pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
494 | + pkt.run(context,packet,bytes); | |
486 | 495 | return result ; |
487 | 496 | }catch (Exception e){ |
488 | 497 | Log_error.error(e.toString()); |
... | ... | @@ -490,7 +499,7 @@ public class WatchServer { |
490 | 499 | return 0l; |
491 | 500 | } |
492 | 501 | |
493 | - private static long insert(XaFeign xaFeign ,String sn ,String functionId , String cardNo , long index , byte[] recv){ | |
502 | + private static long insert(XaFeign xaFeign , String sn ,String functionId , String cardNo , long index , byte[] recv){ | |
494 | 503 | |
495 | 504 | StringBuffer send = new StringBuffer(); |
496 | 505 | for(byte b : recv){ | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WatchingShortHandler.java
... | ... | @@ -1,90 +0,0 @@ |
1 | -package com.sincere.weigeng.utils; | |
2 | - | |
3 | -import org.apache.mina.core.buffer.IoBuffer; | |
4 | -import org.apache.mina.core.service.IoHandlerAdapter; | |
5 | -import org.apache.mina.core.session.IdleStatus; | |
6 | -import org.apache.mina.core.session.IoSession; | |
7 | - | |
8 | -import java.util.Map; | |
9 | -import java.util.Queue; | |
10 | - | |
11 | - | |
12 | -/** | |
13 | - * Class the extends IoHandlerAdapter in order to properly handle | |
14 | - * connections and the data the connections send | |
15 | - * | |
16 | - * @author <a href="http://mina.apache.org" mce_href="http://mina.apache.org">Apache MINA Project</a> | |
17 | - */ | |
18 | -public class WatchingShortHandler extends IoHandlerAdapter { | |
19 | - | |
20 | - private Queue<byte[]> queue; | |
21 | - private Map<Long , IoSession> sessionMap ; | |
22 | - public WatchingShortHandler(Queue<byte[]> queue , Map<Long , IoSession> sessionMap) { | |
23 | - super(); | |
24 | - this.queue = queue; | |
25 | - this.sessionMap = sessionMap; | |
26 | - } | |
27 | - | |
28 | - /** | |
29 | - * 异常来关闭session | |
30 | - */ | |
31 | - @Override | |
32 | - public void exceptionCaught(IoSession session, Throwable cause) | |
33 | - throws Exception { | |
34 | - cause.printStackTrace(); | |
35 | - session.close(true); | |
36 | - } | |
37 | - | |
38 | - /** | |
39 | - * 服务器端收到一个消息 | |
40 | - */ | |
41 | - @Override | |
42 | - public void messageReceived(IoSession session, Object message) throws Exception { | |
43 | - IoBuffer io = (IoBuffer) message; | |
44 | - if (io.hasRemaining()) { | |
45 | - byte[] validBytes = new byte[io.remaining()]; | |
46 | - io.get(validBytes,0,io.remaining()); | |
47 | - if (validBytes.length == WgUdpCommShort.WGPacketSize) { | |
48 | - synchronized (queue) { | |
49 | - long sn = WgUdpCommShort.getLongByByte(validBytes, 4, 4); | |
50 | - sessionMap.put(sn,session); | |
51 | - queue.offer(validBytes); | |
52 | - } | |
53 | - } else { | |
54 | - } | |
55 | - } | |
56 | - } | |
57 | - | |
58 | - @Override | |
59 | - public void sessionClosed(IoSession session) throws Exception { | |
60 | - } | |
61 | - | |
62 | - @Override | |
63 | - public void sessionCreated(IoSession session) throws Exception { | |
64 | - } | |
65 | - | |
66 | - @Override | |
67 | - public void sessionIdle(IoSession session, IdleStatus status) | |
68 | - throws Exception { | |
69 | - } | |
70 | - | |
71 | - @Override | |
72 | - public void sessionOpened(IoSession session) throws Exception { | |
73 | - } | |
74 | - | |
75 | - public Queue<byte[]> getQueue() { | |
76 | - return queue; | |
77 | - } | |
78 | - | |
79 | - public void setQueue(Queue<byte[]> queue) { | |
80 | - this.queue = queue; | |
81 | - } | |
82 | - | |
83 | - public Map<Long, IoSession> getSessionMap() { | |
84 | - return sessionMap; | |
85 | - } | |
86 | - | |
87 | - public void setSessionMap(Map<Long, IoSession> sessionMap) { | |
88 | - this.sessionMap = sessionMap; | |
89 | - } | |
90 | -} |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WgUdpCommShort.java
1 | 1 | package com.sincere.weigeng.utils; |
2 | 2 | |
3 | -import org.apache.mina.core.buffer.IoBuffer; | |
4 | -import org.apache.mina.core.session.IoSession; | |
3 | +import io.netty.buffer.Unpooled; | |
4 | +import io.netty.channel.ChannelHandlerContext; | |
5 | +import io.netty.channel.socket.DatagramPacket; | |
5 | 6 | |
6 | 7 | public class WgUdpCommShort { //短报文协议 |
7 | 8 | |
... | ... | @@ -99,22 +100,9 @@ public class WgUdpCommShort { //短报文协议 |
99 | 100 | return buff; |
100 | 101 | } |
101 | 102 | |
102 | - public void run(IoSession ioSession , byte[] command){ | |
103 | - byte[] bytCommand = command; | |
104 | - IoBuffer b; | |
105 | - Boolean bSent =false; | |
106 | - //ioSession = connFuture.getSession(); | |
107 | - if (ioSession !=null) | |
108 | - { | |
109 | - if (ioSession.isConnected()) | |
110 | - { | |
111 | - b = IoBuffer.allocate(bytCommand.length); | |
112 | - b.put(bytCommand); | |
113 | - b.flip(); | |
114 | - ioSession.write(b); | |
115 | - bSent = true; | |
116 | - } | |
117 | - } | |
118 | - } | |
103 | + public void run(ChannelHandlerContext ctx, DatagramPacket packet , byte[] command ){ | |
104 | + DatagramPacket data = new DatagramPacket(Unpooled.copiedBuffer(command), packet.sender()); | |
105 | + ctx.writeAndFlush(data);//向客户端发送消息 | |
106 | + } | |
119 | 107 | |
120 | 108 | } | ... | ... |
cloud/weigeng/src/main/resources/application.yaml
... | ... | @@ -4,17 +4,13 @@ server: |
4 | 4 | spring: |
5 | 5 | application: |
6 | 6 | name: weigeng-server |
7 | - profiles: | |
8 | - active: dev | |
9 | - | |
10 | 7 | |
11 | 8 | eureka: |
12 | - instance: | |
9 | + instance:2 | |
13 | 10 | hostname: localhost |
14 | 11 | lease-expiration-duration-in-seconds: 60 |
15 | 12 | lease-renewal-interval-in-seconds: 10 |
16 | 13 | client: |
17 | 14 | service-url: |
18 | - # defaultZone: http://localhost:8761/eureka/ | |
19 | 15 | defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ |
20 | 16 | ... | ... |