Commit bb8cc5ddc7a90bff28e95a2ace04b0c017568854
1 parent
3ff150e8
Exists in
master
翼学云同步
Showing
12 changed files
with
291 additions
and
186 deletions
Show diff stats
cloud/quartz/src/main/java/com/sincere/quartz/enums/KqTypeEnums.java
cloud/quartz/src/main/java/com/sincere/quartz/feign/ScFeign.java
... | ... | @@ -73,6 +73,9 @@ public interface ScFeign { |
73 | 73 | @RequestMapping(value = "sm/sync/selectDept",method = RequestMethod.GET) |
74 | 74 | List<SyncDeptDto> selectDept(@RequestParam("schoolId") int schoolId) ; |
75 | 75 | |
76 | + @RequestMapping(value = "sm/sync/selectDeptByGradeId",method = RequestMethod.GET) | |
77 | + SyncDeptDto selectDeptByGradeId(@RequestParam("gradeId") int gradeId); | |
78 | + | |
76 | 79 | @RequestMapping(value = "sm/sync/selectUser",method = RequestMethod.GET) |
77 | 80 | List<SyncUserDto> selectUser(@RequestParam("schoolId") int schoolId); |
78 | 81 | |
... | ... | @@ -96,4 +99,6 @@ public interface ScFeign { |
96 | 99 | |
97 | 100 | @RequestMapping(value = "sm/sync/selectUserYxyIdByHxyId",method = RequestMethod.GET) |
98 | 101 | String selectUserYxyIdByHxyId(@RequestParam("hxyCustomerId") String hxyCustomerId); |
102 | + | |
103 | + | |
99 | 104 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/AlarmJob.java
1 | -package com.sincere.quartz.job; | |
2 | - | |
3 | -import com.alibaba.fastjson.JSONArray; | |
4 | -import com.alibaba.fastjson.JSONObject; | |
5 | -import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | |
6 | -import com.sincere.common.dto.smartCampus.SchoolDto; | |
7 | -import com.sincere.common.util.DateUtils; | |
8 | -import com.sincere.common.util.HttpClientUtils; | |
9 | -import com.sincere.quartz.feign.ScFeign; | |
10 | -import com.sincere.quartz.model.ShortMsg; | |
11 | -import com.sincere.quartz.service.ManagerService; | |
12 | -import com.sincere.quartz.service.SmsService; | |
13 | -import org.springframework.beans.factory.annotation.Autowired; | |
14 | -import org.springframework.scheduling.annotation.Scheduled; | |
15 | -import org.springframework.stereotype.Service; | |
16 | - | |
17 | -import java.util.ArrayList; | |
18 | -import java.util.Date; | |
19 | -import java.util.List; | |
20 | - | |
21 | -/** | |
22 | - * @author chen | |
23 | - * @version 1.0 | |
24 | - * @date 2020/1/3 0003 10:02 | |
25 | - */ | |
26 | -@Service | |
27 | -public class AlarmJob { | |
28 | - | |
29 | - @Autowired | |
30 | - ScFeign scFeign; | |
31 | - | |
32 | - @Autowired | |
33 | - SmsService smsService; | |
34 | - | |
35 | - @Autowired | |
36 | - ManagerService managerService ; | |
37 | - | |
38 | - private static List<String> opexList ; | |
39 | - private static String integration ; | |
40 | - | |
41 | - static{ | |
42 | - opexList = new ArrayList<>(); | |
43 | - opexList.add("15857566147"); //王汉栋 | |
44 | - opexList.add("13858485977"); //王楠彬 | |
45 | - | |
46 | - integration = "18767117554" ; //林炜 | |
47 | - } | |
48 | - | |
49 | - /** | |
50 | - * 设备掉线 | |
51 | - */ | |
52 | - @Scheduled(cron = "0 0 6-18 * * ? ") | |
53 | - public void attendanceAlarm(){ | |
54 | - List<Integer> list = scFeign.selectCloudAttendance(); | |
55 | - for(Integer schoolId : list){ | |
56 | - if(schoolId != 0 && schoolId != 16){ | |
57 | - SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
58 | - List<String> weigengList = new ArrayList<>(); | |
59 | - List<String> faceList = new ArrayList<>(); | |
60 | - List<SZ_AttendanceDto> attendanceList = scFeign.selectCloudAttendanceBySchoolId(schoolId); | |
61 | - for(SZ_AttendanceDto attendanceDto : attendanceList){ | |
62 | - if(attendanceDto.getClint_type().equals("6")){ | |
63 | - //微耕,查询另一张表 | |
64 | - String lastDate = scFeign.selectByDeviceNo(attendanceDto.getClint_id()); | |
65 | - if(lastDate != null){ | |
66 | - if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(lastDate,DateUtils.format2),"s") > 20){ | |
67 | - weigengList.add(attendanceDto.getClint_id()); | |
68 | - } | |
69 | - } | |
70 | - }else { | |
71 | - //人脸 | |
72 | - if(attendanceDto.getIsConnection() == 0){ | |
73 | - faceList.add(attendanceDto.getClint_id()); } | |
74 | - } | |
75 | - } | |
76 | - if(weigengList.size() + faceList.size() > 0){ | |
77 | - //有设备掉线,发送短信 | |
78 | - String msg = "【设备掉线预警】" + schoolDto.getSchoolName() + "!" ; | |
79 | - if(weigengList.size() > 0){ | |
80 | - msg += weigengList.size() + "台闸机掉线。" ; | |
81 | - } | |
82 | - if(faceList.size() > 0){ | |
83 | - msg += faceList.size() + "台人脸机掉线。" ; | |
84 | - } | |
85 | - msg += "请关注。" ; | |
86 | - try{ | |
87 | - sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
88 | - sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
89 | - sendMessage(schoolDto.getSchoolId(),integration,msg); | |
90 | - sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
91 | - }catch (Exception e){ | |
92 | - e.printStackTrace(); | |
93 | - } | |
94 | - } | |
95 | - } | |
96 | - } | |
97 | - } | |
98 | - | |
99 | - | |
100 | - /** | |
101 | - * 卡 脸未下发 | |
102 | - */ | |
103 | - @Scheduled(cron = "0 0 12,18 * * ? ") | |
104 | - public void unPush(){ | |
105 | - List<Integer> list = scFeign.selectCloudAttendance(); | |
106 | - for(Integer schoolId : list) { | |
107 | - if(schoolId != 0 && schoolId != 16){ | |
108 | - SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
109 | - JSONObject schoolResult = getCount(schoolDto); | |
110 | - int cardStudentCount = Integer.valueOf( schoolResult.get("studentCardCount").toString() ); | |
111 | - int successStudentCardCount = Integer.valueOf( schoolResult.get("successStudentCardCount").toString() ); | |
112 | - int fushuCardCount = Integer.valueOf( schoolResult.get("fushuCardCount").toString() ); | |
113 | - int successFushuCardCount = Integer.valueOf( schoolResult.get("successFushuCardCount").toString() ); | |
114 | - int teaCardCount = Integer.valueOf( schoolResult.get("teaCardCount").toString() ); | |
115 | - int successTeaCardCount = Integer.valueOf( schoolResult.get("successTeaCardCount").toString() ); | |
116 | - int totalCardNumber = cardStudentCount + fushuCardCount +teaCardCount ; | |
117 | - int successCardNumber = successFushuCardCount +successStudentCardCount +successTeaCardCount ; | |
118 | - int unSendCard = totalCardNumber-successCardNumber ; | |
119 | - | |
120 | - int errorStudentPhotoCount = Integer.valueOf( schoolResult.get("errorStudentPhotoCount").toString() ); | |
121 | - int errorFushuPhotoCount = Integer.valueOf( schoolResult.get("errorFushuPhotoCount").toString() ); | |
122 | - int errorTeaPhotoCount = Integer.valueOf( schoolResult.get("errorTeaPhotoCount").toString() ); | |
123 | - int unSendFace = errorStudentPhotoCount+errorFushuPhotoCount+errorTeaPhotoCount ; | |
124 | - if(unSendCard + unSendFace > 0) { | |
125 | - String msg = "【人脸卡号下发异常预警】" + schoolDto.getSchoolName() + "!"; | |
126 | - if (unSendCard > 0) { | |
127 | - msg += unSendCard + "卡未下发。"; | |
128 | - } | |
129 | - if (unSendFace > 0) { | |
130 | - msg += unSendFace + "脸未下发。"; | |
131 | - } | |
132 | - msg += "请关注。"; | |
133 | - try { | |
134 | - sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
135 | - sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
136 | - sendMessage(schoolDto.getSchoolId(),integration,msg); | |
137 | - sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
138 | - } catch (Exception e) { | |
139 | - e.printStackTrace(); | |
140 | - } | |
141 | - } | |
142 | - } | |
143 | - } | |
144 | - } | |
145 | - | |
146 | - | |
147 | - public JSONObject getCount(SchoolDto schoolDto){ | |
148 | - JSONObject object = new JSONObject(); | |
149 | - object.put("schoolName",schoolDto.getSchoolName()); | |
150 | - object.put("pageIndex",1); | |
151 | - object.put("pageSize",1); | |
152 | - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/GateServiceManager/GetFacePhotoList",object.toJSONString()); | |
153 | - JSONObject data = (JSONObject) result.get("data"); | |
154 | - JSONArray array = (JSONArray) data.get("list"); | |
155 | - | |
156 | - JSONObject schoolResult = (JSONObject) array.get(0); | |
157 | - return schoolResult ; | |
158 | - } | |
159 | - | |
160 | - private void sendMessage(int schoolId , String mobile , String msg){ | |
161 | - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
162 | - ShortMsg shortMsg = new ShortMsg(); | |
163 | - shortMsg.setTableName("smsNew"+tableSuffix); | |
164 | - shortMsg.setSchoolId(schoolId); | |
165 | - shortMsg.setMobile(mobile); | |
166 | - shortMsg.setMsg(msg); | |
167 | - smsService.insertSMS(shortMsg); | |
168 | - } | |
169 | -} | |
1 | +//package com.sincere.quartz.job; | |
2 | +// | |
3 | +//import com.alibaba.fastjson.JSONArray; | |
4 | +//import com.alibaba.fastjson.JSONObject; | |
5 | +//import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | |
6 | +//import com.sincere.common.dto.smartCampus.SchoolDto; | |
7 | +//import com.sincere.common.util.DateUtils; | |
8 | +//import com.sincere.common.util.HttpClientUtils; | |
9 | +//import com.sincere.quartz.feign.ScFeign; | |
10 | +//import com.sincere.quartz.model.ShortMsg; | |
11 | +//import com.sincere.quartz.service.ManagerService; | |
12 | +//import com.sincere.quartz.service.SmsService; | |
13 | +//import org.apache.commons.lang3.StringUtils; | |
14 | +//import org.springframework.beans.factory.annotation.Autowired; | |
15 | +//import org.springframework.scheduling.annotation.Scheduled; | |
16 | +//import org.springframework.stereotype.Service; | |
17 | +// | |
18 | +//import java.util.ArrayList; | |
19 | +//import java.util.Date; | |
20 | +//import java.util.List; | |
21 | +// | |
22 | +///** | |
23 | +// * @author chen | |
24 | +// * @version 1.0 | |
25 | +// * @date 2020/1/3 0003 10:02 | |
26 | +// */ | |
27 | +//@Service | |
28 | +//public class AlarmJob { | |
29 | +// | |
30 | +// @Autowired | |
31 | +// ScFeign scFeign; | |
32 | +// | |
33 | +// @Autowired | |
34 | +// SmsService smsService; | |
35 | +// | |
36 | +// @Autowired | |
37 | +// ManagerService managerService ; | |
38 | +// | |
39 | +// private static List<String> opexList ; | |
40 | +// private static String integration ; | |
41 | +// | |
42 | +// static{ | |
43 | +// opexList = new ArrayList<>(); | |
44 | +// opexList.add("15857566147"); //王汉栋 | |
45 | +// opexList.add("13858485977"); //王楠彬 | |
46 | +// | |
47 | +// integration = "18767117554" ; //林炜 | |
48 | +// } | |
49 | +// | |
50 | +// /** | |
51 | +// * 设备掉线 | |
52 | +// */ | |
53 | +// @Scheduled(cron = "0 0 6-18 * * MON-FRI") | |
54 | +// public void attendanceAlarm(){ | |
55 | +// List<Integer> list = scFeign.selectCloudAttendance(); | |
56 | +// for(Integer schoolId : list){ | |
57 | +// if(schoolId != 0 && schoolId != 16){ | |
58 | +// SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
59 | +// List<String> weigengList = new ArrayList<>(); | |
60 | +// List<String> faceList = new ArrayList<>(); | |
61 | +// List<SZ_AttendanceDto> attendanceList = scFeign.selectCloudAttendanceBySchoolId(schoolId); | |
62 | +// for(SZ_AttendanceDto attendanceDto : attendanceList){ | |
63 | +// if(attendanceDto.getClint_type().equals("6")){ | |
64 | +// //微耕,查询另一张表 | |
65 | +// String lastDate = scFeign.selectByDeviceNo(attendanceDto.getClint_id()); | |
66 | +// if(lastDate != null){ | |
67 | +// if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(lastDate,DateUtils.format2),"s") > 20){ | |
68 | +// weigengList.add(attendanceDto.getClint_id()); | |
69 | +// } | |
70 | +// } | |
71 | +// }else { | |
72 | +// //人脸 | |
73 | +// if(attendanceDto.getIsConnection() == 0){ | |
74 | +// faceList.add(attendanceDto.getClint_id()); } | |
75 | +// } | |
76 | +// } | |
77 | +// if(weigengList.size() + faceList.size() > 0){ | |
78 | +// //有设备掉线,发送短信 | |
79 | +// String msg = "【设备掉线预警】" + schoolDto.getSchoolName() + "!" ; | |
80 | +// if(weigengList.size() > 0){ | |
81 | +// msg += weigengList.size() + "台闸机掉线。" ; | |
82 | +// } | |
83 | +// if(faceList.size() > 0){ | |
84 | +// msg += faceList.size() + "台人脸机掉线。" ; | |
85 | +// } | |
86 | +// msg += "请关注。" ; | |
87 | +// try{ | |
88 | +// sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
89 | +// sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
90 | +// sendMessage(schoolDto.getSchoolId(),integration,msg); | |
91 | +// sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
92 | +// }catch (Exception e){ | |
93 | +// e.printStackTrace(); | |
94 | +// } | |
95 | +// } | |
96 | +// } | |
97 | +// } | |
98 | +// } | |
99 | +// | |
100 | +// | |
101 | +// /** | |
102 | +// * 卡 脸未下发 | |
103 | +// */ | |
104 | +// @Scheduled(cron = "0 0 12,18 * * MON-FRI") | |
105 | +// public void unPush(){ | |
106 | +// List<Integer> list = scFeign.selectCloudAttendance(); | |
107 | +// for(Integer schoolId : list) { | |
108 | +// if(schoolId != 0 && schoolId != 16){ | |
109 | +// SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
110 | +// JSONObject schoolResult = getCount(schoolDto); | |
111 | +// int cardStudentCount = Integer.valueOf( schoolResult.get("studentCardCount").toString() ); | |
112 | +// int successStudentCardCount = Integer.valueOf( schoolResult.get("successStudentCardCount").toString() ); | |
113 | +// int fushuCardCount = Integer.valueOf( schoolResult.get("fushuCardCount").toString() ); | |
114 | +// int successFushuCardCount = Integer.valueOf( schoolResult.get("successFushuCardCount").toString() ); | |
115 | +// int teaCardCount = Integer.valueOf( schoolResult.get("teaCardCount").toString() ); | |
116 | +// int successTeaCardCount = Integer.valueOf( schoolResult.get("successTeaCardCount").toString() ); | |
117 | +// int totalCardNumber = cardStudentCount + fushuCardCount +teaCardCount ; | |
118 | +// int successCardNumber = successFushuCardCount +successStudentCardCount +successTeaCardCount ; | |
119 | +// int unSendCard = totalCardNumber-successCardNumber ; | |
120 | +// | |
121 | +// int errorStudentPhotoCount = Integer.valueOf( schoolResult.get("errorStudentPhotoCount").toString() ); | |
122 | +// int errorFushuPhotoCount = Integer.valueOf( schoolResult.get("errorFushuPhotoCount").toString() ); | |
123 | +// int errorTeaPhotoCount = Integer.valueOf( schoolResult.get("errorTeaPhotoCount").toString() ); | |
124 | +// int unSendFace = errorStudentPhotoCount+errorFushuPhotoCount+errorTeaPhotoCount ; | |
125 | +// if(unSendCard + unSendFace > 0) { | |
126 | +// String msg = "【人脸卡号下发异常预警】" + schoolDto.getSchoolName() + "!"; | |
127 | +// if (unSendCard > 0) { | |
128 | +// msg += unSendCard + "卡未下发。"; | |
129 | +// } | |
130 | +// if (unSendFace > 0) { | |
131 | +// msg += unSendFace + "脸未下发。"; | |
132 | +// } | |
133 | +// msg += "请关注。"; | |
134 | +// try { | |
135 | +// sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
136 | +// sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
137 | +// sendMessage(schoolDto.getSchoolId(),integration,msg); | |
138 | +// String managerMobile = managerService.selectManagerById(schoolDto.getManagerUserId()) ; | |
139 | +// if(StringUtils.isNotBlank(managerMobile)){ | |
140 | +// sendMessage(schoolDto.getSchoolId(),managerMobile,msg); | |
141 | +// } | |
142 | +// } catch (Exception e) { | |
143 | +// e.printStackTrace(); | |
144 | +// } | |
145 | +// } | |
146 | +// } | |
147 | +// } | |
148 | +// } | |
149 | +// | |
150 | +// | |
151 | +// public JSONObject getCount(SchoolDto schoolDto){ | |
152 | +// JSONObject object = new JSONObject(); | |
153 | +// object.put("schoolName",schoolDto.getSchoolName()); | |
154 | +// object.put("pageIndex",1); | |
155 | +// object.put("pageSize",1); | |
156 | +// JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/GateServiceManager/GetFacePhotoList",object.toJSONString()); | |
157 | +// JSONObject data = (JSONObject) result.get("data"); | |
158 | +// JSONArray array = (JSONArray) data.get("list"); | |
159 | +// | |
160 | +// JSONObject schoolResult = (JSONObject) array.get(0); | |
161 | +// return schoolResult ; | |
162 | +// } | |
163 | +// | |
164 | +// private void sendMessage(int schoolId , String mobile , String msg){ | |
165 | +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
166 | +// ShortMsg shortMsg = new ShortMsg(); | |
167 | +// shortMsg.setTableName("smsNew"+tableSuffix); | |
168 | +// shortMsg.setSchoolId(schoolId); | |
169 | +// shortMsg.setMobile(mobile); | |
170 | +// shortMsg.setMsg(msg); | |
171 | +// smsService.insertSMS(shortMsg); | |
172 | +// } | |
173 | +//} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
... | ... | @@ -45,6 +45,8 @@ public class KQJob { |
45 | 45 | @Autowired |
46 | 46 | ManagerService managerService ; |
47 | 47 | |
48 | + private static String iotUrl = "http://60.190.202.57:8035"; | |
49 | + | |
48 | 50 | private static String date ; |
49 | 51 | private static Map<String , String> map = new HashMap<>(); //学校 考勤推送map |
50 | 52 | |
... | ... | @@ -98,7 +100,7 @@ public class KQJob { |
98 | 100 | } |
99 | 101 | } |
100 | 102 | |
101 | - @Scheduled(cron = "0 0 18 * * MON-FRI") | |
103 | + @Scheduled(cron = "0 0-59 * * * ? ") | |
102 | 104 | public void alarmKaoQing() { |
103 | 105 | String now = DateUtils.date2String(new Date(),DateUtils.format1) ; |
104 | 106 | if(StringUtils.isBlank(alarmDate)){ |
... | ... | @@ -117,7 +119,8 @@ public class KQJob { |
117 | 119 | ){ |
118 | 120 | String key = entity.getKey(); |
119 | 121 | keyList.add(key); |
120 | - alarm(entity); | |
122 | + //alarm(entity); //告警 | |
123 | + //insertIOT(entity); //iot | |
121 | 124 | } |
122 | 125 | } |
123 | 126 | for(String key : keyList){ |
... | ... | @@ -142,9 +145,9 @@ public class KQJob { |
142 | 145 | String type = msg.substring(msg.indexOf("Type")+6,msg.indexOf("Type")+8); |
143 | 146 | type = type.replace("\"",""); |
144 | 147 | int nowWeek = DateUtils.getWeek() ; |
145 | - if(Week.contains(nowWeek+"") && nowWeek != 1 && nowWeek != 7 ){ //周末不告警 | |
148 | + if(Week.contains(nowWeek+"") && nowWeek != 6 && nowWeek != 0 ){ //周末不告警 | |
146 | 149 | logger.info((templateId+"_"+templateDto.getSchoolId()+"------"+beginTime+"_"+endTime)); |
147 | - alarmMap.put(templateId+"_"+templateDto.getSchoolId() , beginTime+"_"+endTime+"_"+type+"_"+templateDto.getId()); | |
150 | + alarmMap.put(templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getTitle() , beginTime+"_"+endTime+"_"+type+"_"+templateDto.getId()); | |
148 | 151 | } |
149 | 152 | }catch (Exception e){ |
150 | 153 | e.printStackTrace(); |
... | ... | @@ -159,7 +162,8 @@ public class KQJob { |
159 | 162 | String schoolId = entry.getKey().split("_")[1] ; |
160 | 163 | String id = entry.getValue().split("_")[3]; |
161 | 164 | String type = entry.getValue().split("_")[2] ; |
162 | - if(DateUtils.getWeek() == 3 || DateUtils.getWeek() == 6){ | |
165 | + | |
166 | + if(DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5){ | |
163 | 167 | //可以相差40% |
164 | 168 | BigDecimal percent = getAlarmCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type)); |
165 | 169 | if(templateMap.get(templateId) != null){ |
... | ... | @@ -182,6 +186,30 @@ public class KQJob { |
182 | 186 | } |
183 | 187 | } |
184 | 188 | |
189 | + private void insertIOT(Map.Entry<String,String> entry){ | |
190 | + String templateId = entry.getKey().split("_")[0] ; | |
191 | + String schoolId = entry.getKey().split("_")[1] ; | |
192 | + String title = entry.getKey().split("_")[2] ; | |
193 | + String id = entry.getValue().split("_")[3]; | |
194 | + String type = entry.getValue().split("_")[2] ; | |
195 | + String beginTime = entry.getValue().split("_")[0] ; | |
196 | + String endTime = entry.getValue().split("_")[1] ; | |
197 | + | |
198 | + List<Integer> list = getIOTCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type)) ; | |
199 | + JSONObject object = new JSONObject(); | |
200 | + object.put("strTime",beginTime); | |
201 | + object.put("endTime",endTime); | |
202 | + object.put("inTime",DateUtils.date2String(new Date(),DateUtils.format1)); | |
203 | + object.put("noAttendanceCount",list.get(1)); | |
204 | + object.put("attendanceCount",list.get(0)); | |
205 | + object.put("leaveCount",list.get(2)); | |
206 | + object.put("templateName",title); | |
207 | + object.put("qianDaoIdId",id); | |
208 | + object.put("schoolId",schoolId); | |
209 | + object.put("templateId",templateId); | |
210 | + HttpClientUtils.httpPostJson(iotUrl+"/api/Association/addIntelligenceAttendance",object.toJSONString()); | |
211 | + } | |
212 | + | |
185 | 213 | //初始化要推送的模板 |
186 | 214 | private void initMap(){ |
187 | 215 | map = new HashMap<>(); |
... | ... | @@ -436,7 +464,44 @@ public class KQJob { |
436 | 464 | e.printStackTrace(); |
437 | 465 | } |
438 | 466 | } |
439 | - return new BigDecimal(attendNumber).divide(new BigDecimal(allNumber)) ; | |
467 | + if(allNumber != 0){ | |
468 | + BigDecimal pecrent = new BigDecimal(attendNumber).divide(new BigDecimal(allNumber),10, BigDecimal.ROUND_HALF_DOWN) ; | |
469 | + return pecrent ; | |
470 | + }else { | |
471 | + return BigDecimal.ZERO ; | |
472 | + } | |
473 | + | |
474 | + } | |
475 | + | |
476 | + /** | |
477 | + * | |
478 | + * @param id | |
479 | + * @param templateId | |
480 | + * @param schoolId | |
481 | + * @param type | |
482 | + * @return list(0) 出勤 list(1) 未出勤 List(2) 请假 | |
483 | + */ | |
484 | + private List<Integer> getIOTCensus(int id , String templateId ,int schoolId , int type){ | |
485 | + List<Integer> result = new ArrayList<>(); | |
486 | + int attend = 0 , unattend = 0 , leave = 0; | |
487 | + List<Integer> list = scFeign.selectClassBySchoolId(schoolId); | |
488 | + for(Integer classId : list){ | |
489 | + String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId="+classId+ | |
490 | + "&id="+id+"&templateID="+templateId+"&type="+type+"&time=" + DateUtils.date2String(new Date(),DateUtils.format1); | |
491 | + JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
492 | + try{ | |
493 | + JSONObject data = (JSONObject) jsonObject.get("data"); | |
494 | + attend = attend + (Integer) data.get("stuAttendCount"); | |
495 | + unattend = unattend + (Integer) data.get("noAttendCount"); | |
496 | + leave = leave + (Integer) data.get("leaveCount"); | |
497 | + }catch (Exception e){ | |
498 | + e.printStackTrace(); | |
499 | + } | |
500 | + } | |
501 | + result.add(attend); | |
502 | + result.add(unattend); | |
503 | + result.add(leave); | |
504 | + return result ; | |
440 | 505 | } |
441 | 506 | |
442 | 507 | |
... | ... | @@ -464,7 +529,10 @@ public class KQJob { |
464 | 529 | sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); |
465 | 530 | sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); |
466 | 531 | sendMessage(schoolDto.getSchoolId(),integration,msg); |
467 | - sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
532 | + String managerPhone = managerService.selectManagerById(schoolDto.getManagerUserId()) ; | |
533 | + if(StringUtils.isNotBlank(managerPhone)){ | |
534 | + sendMessage(schoolDto.getSchoolId(),managerPhone,msg); | |
535 | + } | |
468 | 536 | }catch (Exception e){ |
469 | 537 | e.printStackTrace(); |
470 | 538 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
... | ... | @@ -20,11 +20,10 @@ public class SyncJob { |
20 | 20 | @Autowired |
21 | 21 | YXYReadService yxyReadService ; |
22 | 22 | |
23 | - //@Scheduled(cron = "0/1 * * * * ? ") | |
24 | - //@Scheduled(cron = "0 0 23 * * ? ") | |
23 | + @Scheduled(cron = "0 0 23 * * ? ") | |
25 | 24 | public void Sync(){ |
26 | 25 | //翼校通的同步 之后还有钉钉的同步等等 |
27 | - //yxyWriteService.sync(); | |
28 | - yxyReadService.sync(); | |
26 | + yxyWriteService.sync(); | |
27 | + //yxyReadService.sync(); | |
29 | 28 | } |
30 | 29 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYReadService.java
... | ... | @@ -44,9 +44,9 @@ public class YXYReadService { |
44 | 44 | list.add(SI); |
45 | 45 | list.add(getPassword(SI_CODE)); |
46 | 46 | list.add("05750400"); |
47 | - String wsdl =getAllStudent ; | |
47 | + String wsdl =getAllTeacher ; | |
48 | 48 | String ns = nameSpace; |
49 | - String method = getALlStudent_method; | |
49 | + String method = getAllTeacher_method; | |
50 | 50 | JSONArray jsonArray = getMessage(wsdl, ns, method, list); |
51 | 51 | System.out.println(jsonArray.toJSONString()); |
52 | 52 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYWriteService.java
... | ... | @@ -7,6 +7,8 @@ import com.sincere.common.dto.smartCampus.*; |
7 | 7 | import com.sincere.common.util.HttpClientUtils; |
8 | 8 | import com.sincere.quartz.feign.ScFeign; |
9 | 9 | import org.apache.commons.lang3.StringUtils; |
10 | +import org.slf4j.Logger; | |
11 | +import org.slf4j.LoggerFactory; | |
10 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
11 | 13 | import org.springframework.stereotype.Service; |
12 | 14 | |
... | ... | @@ -20,6 +22,9 @@ import java.util.List; |
20 | 22 | */ |
21 | 23 | @Service |
22 | 24 | public class YXYWriteService { |
25 | + | |
26 | + private Logger logger = LoggerFactory.getLogger(YXYWriteService.class); | |
27 | + | |
23 | 28 | private String TOKEN="" ; |
24 | 29 | |
25 | 30 | private static String key = "SZKJ"; |
... | ... | @@ -47,8 +52,10 @@ public class YXYWriteService { |
47 | 52 | |
48 | 53 | public void sync(){ |
49 | 54 | //查出要同步的学校 |
55 | + logger.info("开始同步翼学云数据==========="); | |
50 | 56 | List<SyncSchoolDto> schoolList = scFeign.selectSyncSchool(); |
51 | 57 | for(SyncSchoolDto school : schoolList){ |
58 | + logger.info("学校"+school.getSchoolName()); | |
52 | 59 | if(school.getPush() == 0){ |
53 | 60 | //同步课程 |
54 | 61 | syncSubject(school); |
... | ... | @@ -159,6 +166,7 @@ public class YXYWriteService { |
159 | 166 | JSONArray array = initAddJson(addDept,school.getYxtId()); |
160 | 167 | YXYResult result = getResult(prefix_url+suffix_org_add,array.toJSONString()); |
161 | 168 | if(result.getCode() == 0 || result.getCode() == -3){ |
169 | + logger.info("同步组织架构:total:" + result.getTotal() + ";pass:"+result.getPass()); | |
162 | 170 | for(YXYResultDetail detail : result.getData()){ |
163 | 171 | if(StringUtils.isNotBlank(detail.getId())){ |
164 | 172 | //成功 |
... | ... | @@ -238,6 +246,7 @@ public class YXYWriteService { |
238 | 246 | JSONArray array = initAddJson(addGrade,school.getYxtId()); |
239 | 247 | YXYResult result = getResult(prefix_url+suffix_grade_add,array.toJSONString()); |
240 | 248 | if(result.getCode() == 0 || result.getCode() == -3){ |
249 | + logger.info("同步年级:total:" + result.getTotal() + ";pass:"+result.getPass()); | |
241 | 250 | for(YXYResultDetail detail : result.getData()){ |
242 | 251 | if(StringUtils.isNotBlank(detail.getId())){ |
243 | 252 | //成功 |
... | ... | @@ -317,6 +326,7 @@ public class YXYWriteService { |
317 | 326 | JSONArray array = initClassAddJson(addClass); |
318 | 327 | YXYResult result = getResult(prefix_url+suffix_class_add,array.toJSONString()); |
319 | 328 | if(result.getCode() == 0 || result.getCode() == -3){ |
329 | + logger.info("同步班级:total:" + result.getTotal() + ";pass:"+result.getPass()); | |
320 | 330 | for(YXYResultDetail detail : result.getData()){ |
321 | 331 | if(StringUtils.isNotBlank(detail.getClassid())){ |
322 | 332 | //成功 |
... | ... | @@ -396,6 +406,7 @@ public class YXYWriteService { |
396 | 406 | JSONArray array = initAddJson(addStudentList); |
397 | 407 | YXYResult result = getResult(prefix_url+suffix_student_add,array.toJSONString()); |
398 | 408 | if(result.getCode() == 0 || result.getCode() == -3){ |
409 | + logger.info("同步学生:total:" + result.getTotal() + ";pass:"+result.getPass()); | |
399 | 410 | for(YXYResultDetail detail : result.getData()){ |
400 | 411 | if(StringUtils.isNotBlank(detail.getUserid())){ |
401 | 412 | //成功 |
... | ... | @@ -473,6 +484,7 @@ public class YXYWriteService { |
473 | 484 | JSONArray array = initTeacherAddJson(school,addTeacherList); |
474 | 485 | YXYResult result = getResult(prefix_url+suffix_teacher_add,array.toJSONString()); |
475 | 486 | if(result.getCode() == 0 || result.getCode() == -3){ |
487 | + logger.info("同步老师:total:" + result.getTotal() + ";pass:"+result.getPass()); | |
476 | 488 | for(YXYResultDetail detail : result.getData()){ |
477 | 489 | if(StringUtils.isNotBlank(detail.getUserid())){ |
478 | 490 | //成功 |
... | ... | @@ -554,7 +566,7 @@ public class YXYWriteService { |
554 | 566 | object.put("schoolid",yxtId); |
555 | 567 | object.put("name",deptDto.getDeptName()); |
556 | 568 | if(deptDto.getGradeId() != 0){ |
557 | - object.put("groupname",getDept(list,deptDto.getGradeId()).getDeptName()); | |
569 | + object.put("groupname",scFeign.selectDeptByGradeId(deptDto.getGradeId()).getDeptName()); | |
558 | 570 | } |
559 | 571 | array.add(object); |
560 | 572 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/SyncController.java
... | ... | @@ -69,6 +69,11 @@ public class SyncController { |
69 | 69 | return syncService.selectUser(schoolId); |
70 | 70 | } |
71 | 71 | |
72 | + @RequestMapping(value = "selectDeptByGradeId",method = RequestMethod.GET) | |
73 | + SyncDeptDto selectDeptByGradeId(@RequestParam("gradeId") int gradeId){ | |
74 | + return syncService.selectDeptByGradeId(gradeId); | |
75 | + } | |
76 | + | |
72 | 77 | @RequestMapping(value = "selectYxyIdByHxyId",method = RequestMethod.GET) |
73 | 78 | String selectYxyIdByHxyId(@RequestParam("hxyId") int hxyId){ |
74 | 79 | return syncService.selectYxyIdByHxyId(hxyId); | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/SyncMapper.java
... | ... | @@ -26,6 +26,8 @@ public interface SyncMapper { |
26 | 26 | |
27 | 27 | List<SyncDeptDto> selectDept(int schoolId) ; |
28 | 28 | |
29 | + SyncDeptDto selectDeptByGradeId(int gradeId); | |
30 | + | |
29 | 31 | List<SyncUserDto> selectUser(int schoolId); |
30 | 32 | |
31 | 33 | int insertDeptRelation(DeptRelationDto deptRelationDto); | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/SyncService.java
... | ... | @@ -25,6 +25,8 @@ public interface SyncService { |
25 | 25 | |
26 | 26 | List<SyncDeptDto> selectDept(int schoolId) ; |
27 | 27 | |
28 | + SyncDeptDto selectDeptByGradeId(int gradeId); | |
29 | + | |
28 | 30 | List<SyncUserDto> selectUser(int schoolId); |
29 | 31 | |
30 | 32 | int insertDeptRelation(DeptRelationDto deptRelationDto); | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/SyncServiceImpl.java
... | ... | @@ -55,6 +55,11 @@ public class SyncServiceImpl implements SyncService { |
55 | 55 | } |
56 | 56 | |
57 | 57 | @Override |
58 | + public SyncDeptDto selectDeptByGradeId(int gradeId) { | |
59 | + return syncMapper.selectDeptByGradeId(gradeId); | |
60 | + } | |
61 | + | |
62 | + @Override | |
58 | 63 | public List<SyncUserDto> selectUser(int schoolId) { |
59 | 64 | return syncMapper.selectUser(schoolId); |
60 | 65 | } | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/SyncMapper.xml
... | ... | @@ -40,7 +40,12 @@ |
40 | 40 | </resultMap> |
41 | 41 | <select id="selectDept" parameterType="java.lang.Integer" resultMap="DeptDto"> |
42 | 42 | select ID , Dept_id , schoolid , Dept_name ,UpdateType ,gradeId , usertype from HS_TeaGroupUpdate where schoolid = #{schoolId} |
43 | - and yxy_is_new = 0 | |
43 | + and yxy_is_new = 0 order by ID | |
44 | + </select> | |
45 | + | |
46 | + <select id="selectDeptByGradeId" parameterType="java.lang.Integer" resultMap="DeptDto"> | |
47 | + select ID , Dept_id , schoolid , Dept_name ,UpdateType ,gradeId , usertype from HS_TeaGroupUpdate | |
48 | + where gradeId = #{gradeId} | |
44 | 49 | </select> |
45 | 50 | |
46 | 51 | <update id="updateDept" parameterType="java.lang.Integer" > | ... | ... |