Commit 124aa27a05ba9e93f32547982e6a3e08330b2ef7
1 parent
a5f89221
Exists in
master
体温上传 博冠人脸
Showing
14 changed files
with
544 additions
and
169 deletions
Show diff stats
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/CwStutemperaturereocrd.java
0 → 100644
@@ -0,0 +1,106 @@ | @@ -0,0 +1,106 @@ | ||
1 | +package com.sincere.common.dto.smartCampus; | ||
2 | + | ||
3 | +import java.math.BigDecimal; | ||
4 | +import java.util.Date; | ||
5 | + | ||
6 | +public class CwStutemperaturereocrd { | ||
7 | + private Integer id; | ||
8 | + | ||
9 | + private String userid; | ||
10 | + | ||
11 | + private Integer studentid; | ||
12 | + | ||
13 | + private String name; | ||
14 | + | ||
15 | + private Integer classid; | ||
16 | + | ||
17 | + private String classname; | ||
18 | + | ||
19 | + private BigDecimal temperature; | ||
20 | + | ||
21 | + private Integer type; | ||
22 | + | ||
23 | + private Integer schoolid; | ||
24 | + | ||
25 | + private Date intime; | ||
26 | + | ||
27 | + public Integer getId() { | ||
28 | + return id; | ||
29 | + } | ||
30 | + | ||
31 | + public void setId(Integer id) { | ||
32 | + this.id = id; | ||
33 | + } | ||
34 | + | ||
35 | + public String getUserid() { | ||
36 | + return userid; | ||
37 | + } | ||
38 | + | ||
39 | + public void setUserid(String userid) { | ||
40 | + this.userid = userid; | ||
41 | + } | ||
42 | + | ||
43 | + public Integer getStudentid() { | ||
44 | + return studentid; | ||
45 | + } | ||
46 | + | ||
47 | + public void setStudentid(Integer studentid) { | ||
48 | + this.studentid = studentid; | ||
49 | + } | ||
50 | + | ||
51 | + public String getName() { | ||
52 | + return name; | ||
53 | + } | ||
54 | + | ||
55 | + public void setName(String name) { | ||
56 | + this.name = name; | ||
57 | + } | ||
58 | + | ||
59 | + public Integer getClassid() { | ||
60 | + return classid; | ||
61 | + } | ||
62 | + | ||
63 | + public void setClassid(Integer classid) { | ||
64 | + this.classid = classid; | ||
65 | + } | ||
66 | + | ||
67 | + public String getClassname() { | ||
68 | + return classname; | ||
69 | + } | ||
70 | + | ||
71 | + public void setClassname(String classname) { | ||
72 | + this.classname = classname; | ||
73 | + } | ||
74 | + | ||
75 | + public BigDecimal getTemperature() { | ||
76 | + return temperature; | ||
77 | + } | ||
78 | + | ||
79 | + public void setTemperature(BigDecimal temperature) { | ||
80 | + this.temperature = temperature; | ||
81 | + } | ||
82 | + | ||
83 | + public Integer getType() { | ||
84 | + return type; | ||
85 | + } | ||
86 | + | ||
87 | + public void setType(Integer type) { | ||
88 | + this.type = type; | ||
89 | + } | ||
90 | + | ||
91 | + public Integer getSchoolid() { | ||
92 | + return schoolid; | ||
93 | + } | ||
94 | + | ||
95 | + public void setSchoolid(Integer schoolid) { | ||
96 | + this.schoolid = schoolid; | ||
97 | + } | ||
98 | + | ||
99 | + public Date getIntime() { | ||
100 | + return intime; | ||
101 | + } | ||
102 | + | ||
103 | + public void setIntime(Date intime) { | ||
104 | + this.intime = intime; | ||
105 | + } | ||
106 | +} | ||
0 | \ No newline at end of file | 107 | \ No newline at end of file |
cloud/lapi/src/main/java/com/sincere/lapi/controller/LapiController.java
1 | package com.sincere.lapi.controller; | 1 | package com.sincere.lapi.controller; |
2 | 2 | ||
3 | -import com.alibaba.fastjson.JSONArray; | ||
4 | -import com.alibaba.fastjson.JSONObject; | ||
5 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; | 3 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; |
6 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; | 4 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; |
7 | -import com.sincere.common.dto.xiaoan.FaceSendfail; | ||
8 | -import com.sincere.common.dto.xiaoan.FaceSendsuccess; | ||
9 | import com.sincere.lapi.Utils.FileUtils; | 5 | import com.sincere.lapi.Utils.FileUtils; |
10 | import com.sincere.lapi.feign.ScFeign; | 6 | import com.sincere.lapi.feign.ScFeign; |
11 | import com.sincere.lapi.feign.XaFeign; | 7 | import com.sincere.lapi.feign.XaFeign; |
@@ -39,21 +35,6 @@ public class LapiController { | @@ -39,21 +35,6 @@ public class LapiController { | ||
39 | @Autowired | 35 | @Autowired |
40 | TerminalHttpCall terminalHttpCall = new TerminalHttpCall(); | 36 | TerminalHttpCall terminalHttpCall = new TerminalHttpCall(); |
41 | 37 | ||
42 | - | ||
43 | - private static Map<Integer,String> resultCodeMap = new HashMap<>(); | ||
44 | - | ||
45 | - static { | ||
46 | - resultCodeMap.put(1,"通用执行失败"); | ||
47 | - resultCodeMap.put(2,"初始化检测失败"); | ||
48 | - resultCodeMap.put(3,"人脸检测失败"); | ||
49 | - resultCodeMap.put(4,"图片未检测到人脸"); | ||
50 | - resultCodeMap.put(5,"jpeg 照片解码失败"); | ||
51 | - resultCodeMap.put(6,"人脸图片质量分数不满足"); | ||
52 | - resultCodeMap.put(7,"图片缩放失败"); | ||
53 | - resultCodeMap.put(8,"未启用智能"); | ||
54 | - resultCodeMap.put(9,"图片不存在或过大/过小"); | ||
55 | - } | ||
56 | - | ||
57 | /** | 38 | /** |
58 | * 下发整个学校 | 39 | * 下发整个学校 |
59 | * @param deviceIds 多个设备用,隔开 | 40 | * @param deviceIds 多个设备用,隔开 |
@@ -114,27 +95,7 @@ public class LapiController { | @@ -114,27 +95,7 @@ public class LapiController { | ||
114 | } | 95 | } |
115 | 96 | ||
116 | private void sendStudent(SzVSchoolStudent student , String deviceId){ | 97 | private void sendStudent(SzVSchoolStudent student , String deviceId){ |
117 | - try{ | ||
118 | - LAPIResponse response = sendImg(Long.valueOf(student.getStudentId()),student.getName(),student.getStudentNum(),student.getPhoto(),deviceId); | ||
119 | - terminalHttpCall.removeKey(deviceId); | ||
120 | - if(response.getStatusString().equals("Succeed")){ | ||
121 | - JSONObject data = JSONObject.parseObject(response.getData()); | ||
122 | - JSONArray personList = (JSONArray)data.get("PersonList") ; | ||
123 | - JSONArray faceList = (JSONArray) ((JSONObject)personList.get(0)).get("FaceList"); | ||
124 | - JSONObject face = (JSONObject) faceList.get(0); | ||
125 | - if((Integer) face.get("ResultCode") == 0){ | ||
126 | - insertSuccess(deviceId,student.getStudentId(),student.getStudentNum(),student.getName(),student.getPhoto(),student.getSchoolId(),2); | ||
127 | - }else { | ||
128 | - Integer code = (Integer) face.get("ResultCode") ; | ||
129 | - insertFail(deviceId,student.getStudentId(),student.getStudentNum(),student.getName(),student.getPhoto(),student.getSchoolId(),2,code,resultCodeMap.get(code)); | ||
130 | - } | ||
131 | - }else { | ||
132 | - insertFail(deviceId,student.getStudentId(),student.getStudentNum(),student.getName(),student.getPhoto(),student.getSchoolId(),2,response.getStatusCode(),response.getStatusString()); | ||
133 | - } | ||
134 | - }catch (Exception e){ | ||
135 | - e.printStackTrace(); | ||
136 | - } | ||
137 | - | 98 | + sendImg(Long.valueOf(student.getStudentId()),student.getName(),student.getStudentNum(),student.getPhoto(),deviceId,2); |
138 | } | 99 | } |
139 | 100 | ||
140 | private void sendTeacherBatch( List<SzVSchoolTeacher> list , String deviceId){ | 101 | private void sendTeacherBatch( List<SzVSchoolTeacher> list , String deviceId){ |
@@ -146,31 +107,11 @@ public class LapiController { | @@ -146,31 +107,11 @@ public class LapiController { | ||
146 | } | 107 | } |
147 | 108 | ||
148 | private void sendTeacher(SzVSchoolTeacher teacher , String deviceId){ | 109 | private void sendTeacher(SzVSchoolTeacher teacher , String deviceId){ |
149 | - try{ | ||
150 | - LAPIResponse response = sendImg(Long.valueOf(teacher.getTeacherId()),teacher.getName(),teacher.getTeacherNum(),teacher.getFace(),deviceId); | ||
151 | - terminalHttpCall.removeKey(deviceId); | ||
152 | - if(response.getStatusString().equals("Succeed")){ | ||
153 | - JSONObject data = JSONObject.parseObject(response.getData()); | ||
154 | - JSONArray personList = (JSONArray)data.get("PersonList") ; | ||
155 | - JSONArray faceList = (JSONArray) ((JSONObject)personList.get(0)).get("FaceList"); | ||
156 | - JSONObject face = (JSONObject) faceList.get(0); | ||
157 | - if((Integer) face.get("ResultCode") == 0){ | ||
158 | - insertSuccess(deviceId,teacher.getTeacherId(),teacher.getTeacherNum(),teacher.getName(),teacher.getFace(),teacher.getSchoolId(),1); | ||
159 | - }else { | ||
160 | - Integer code = (Integer) face.get("ResultCode") ; | ||
161 | - insertFail(deviceId,teacher.getTeacherId(),teacher.getTeacherNum(),teacher.getName(),teacher.getFace(),teacher.getSchoolId(),1,code,resultCodeMap.get(code)); | ||
162 | - } | ||
163 | - }else { | ||
164 | - insertFail(deviceId,teacher.getTeacherId(),teacher.getTeacherNum(),teacher.getName(),teacher.getFace(),teacher.getSchoolId(),1,response.getStatusCode(),response.getStatusString()); | ||
165 | - } | ||
166 | - }catch (Exception e){ | ||
167 | - e.printStackTrace(); | ||
168 | - } | 110 | + sendImg(Long.valueOf(teacher.getTeacherId()),teacher.getName(),teacher.getTeacherNum(),teacher.getFace(),deviceId,1); |
169 | 111 | ||
170 | } | 112 | } |
171 | 113 | ||
172 | - private LAPIResponse sendImg(long personId , String name , String code , String fileUrl , String deviceId){ | ||
173 | - LAPIResponse response = new LAPIResponse() ; | 114 | + private void sendImg(long personId , String name , String code , String fileUrl , String deviceId , int userType){ |
174 | PersonInfoList personInfoList = new PersonInfoList(); | 115 | PersonInfoList personInfoList = new PersonInfoList(); |
175 | List<PersonInfo> list1 = new ArrayList<PersonInfo>(); | 116 | List<PersonInfo> list1 = new ArrayList<PersonInfo>(); |
176 | personInfoList.setPersonInfoList(list1); | 117 | personInfoList.setPersonInfoList(list1); |
@@ -203,27 +144,16 @@ public class LapiController { | @@ -203,27 +144,16 @@ public class LapiController { | ||
203 | String picture = new BASE64Encoder().encode(FileUtils.getBytes(fileUrl)); | 144 | String picture = new BASE64Encoder().encode(FileUtils.getBytes(fileUrl)); |
204 | picture = picture.replaceAll("\n", "").replaceAll("\r", ""); | 145 | picture = picture.replaceAll("\n", "").replaceAll("\r", ""); |
205 | personImageInfo.setData(picture); | 146 | personImageInfo.setData(picture); |
206 | - personImageInfo.setFaceID(1L); | 147 | + personImageInfo.setFaceID(Long.valueOf(userType)); |
207 | //personImageInfo.setName("1.jpg"); | 148 | //personImageInfo.setName("1.jpg"); |
208 | personImageInfo.setSize(picture.length()); | 149 | personImageInfo.setSize(picture.length()); |
209 | imageList.add(personImageInfo); | 150 | imageList.add(personImageInfo); |
210 | personInfo.setImageList(imageList); | 151 | personInfo.setImageList(imageList); |
211 | personInfo.setImageNum(imageList.size()); | 152 | personInfo.setImageNum(imageList.size()); |
212 | terminalHttpCall.addPerson(deviceId, personInfoList); | 153 | terminalHttpCall.addPerson(deviceId, personInfoList); |
213 | - | ||
214 | - Thread.sleep(2000); | ||
215 | - try{ | ||
216 | - response = terminalHttpCall.getResponse(deviceId); | ||
217 | - response.getStatusString(); | ||
218 | - }catch (Exception e){ | ||
219 | - Thread.sleep(5000); | ||
220 | - response = terminalHttpCall.getResponse(deviceId); | ||
221 | - } | ||
222 | - | ||
223 | } catch(Exception e) { | 154 | } catch(Exception e) { |
224 | - System.out.println("下发失败"+e.getMessage()); | 155 | + System.out.println(e.getMessage()); |
225 | } | 156 | } |
226 | - return response ; | ||
227 | } | 157 | } |
228 | 158 | ||
229 | 159 | ||
@@ -243,31 +173,4 @@ public class LapiController { | @@ -243,31 +173,4 @@ public class LapiController { | ||
243 | } | 173 | } |
244 | } | 174 | } |
245 | 175 | ||
246 | - private void insertSuccess(String deviceId , int customerId , String num , String name , String imgPath , int schoolId ,int userType){ | ||
247 | - FaceSendsuccess send = new FaceSendsuccess(); | ||
248 | - send.setDeviceid(deviceId); | ||
249 | - send.setCustomerid(customerId+""); | ||
250 | - send.setDevicetype(25); | ||
251 | - send.setImgpath(imgPath); | ||
252 | - send.setSchoolid(schoolId); | ||
253 | - send.setUsertype(userType); | ||
254 | - send.setName(name); | ||
255 | - send.setNum(num); | ||
256 | - xaFeign.insertFaceSuccess(send); | ||
257 | - } | ||
258 | - | ||
259 | - private void insertFail(String deviceId , int customerId , String num , String name , String imgPath , int schoolId ,int userType , int failType ,String failContent){ | ||
260 | - FaceSendfail send = new FaceSendfail(); | ||
261 | - send.setDeviceid(deviceId); | ||
262 | - send.setCustomerid(customerId+""); | ||
263 | - send.setDevicetype(25); | ||
264 | - send.setImgpath(imgPath); | ||
265 | - send.setSchoolid(schoolId); | ||
266 | - send.setUsertype(userType); | ||
267 | - send.setName(name); | ||
268 | - send.setNum(num); | ||
269 | - send.setFailtype(failType); | ||
270 | - send.setFailcontent(failContent); | ||
271 | - xaFeign.insertFaceFail(send); | ||
272 | - } | ||
273 | -} | 176 | + } |
cloud/lapi/src/main/java/com/sincere/lapi/feign/ScFeign.java
1 | package com.sincere.lapi.feign; | 1 | package com.sincere.lapi.feign; |
2 | 2 | ||
3 | +import com.sincere.common.dto.smartCampus.CwStutemperaturereocrd; | ||
3 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | 4 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
4 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; | 5 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; |
5 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; | 6 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; |
@@ -19,6 +20,9 @@ import java.util.List; | @@ -19,6 +20,9 @@ import java.util.List; | ||
19 | @FeignClient("smartCampusSearch") | 20 | @FeignClient("smartCampusSearch") |
20 | public interface ScFeign { | 21 | public interface ScFeign { |
21 | 22 | ||
23 | + @RequestMapping(value = "/sm/user/insertTemperature",method = RequestMethod.POST) | ||
24 | + int insertTemperature(@RequestBody CwStutemperaturereocrd record); | ||
25 | + | ||
22 | @RequestMapping(value = "/attendance/addAttendance", method = RequestMethod.POST) | 26 | @RequestMapping(value = "/attendance/addAttendance", method = RequestMethod.POST) |
23 | void addAttendance(@RequestBody SZ_AttendanceDto attendanceDto); | 27 | void addAttendance(@RequestBody SZ_AttendanceDto attendanceDto); |
24 | 28 |
cloud/lapi/src/main/java/com/sincere/lapi/server/handler/HttpClientHandler.java
1 | package com.sincere.lapi.server.handler; | 1 | package com.sincere.lapi.server.handler; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONArray; | ||
3 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
4 | import com.sincere.common.util.DateUtils; | 5 | import com.sincere.common.util.DateUtils; |
5 | import com.sincere.lapi.Utils.SpringContextHolder; | 6 | import com.sincere.lapi.Utils.SpringContextHolder; |
@@ -20,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; | @@ -20,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; | ||
20 | import org.slf4j.Logger; | 21 | import org.slf4j.Logger; |
21 | import org.slf4j.LoggerFactory; | 22 | import org.slf4j.LoggerFactory; |
22 | 23 | ||
24 | +import java.math.BigDecimal; | ||
23 | import java.text.SimpleDateFormat; | 25 | import java.text.SimpleDateFormat; |
24 | import java.util.Date; | 26 | import java.util.Date; |
25 | 27 | ||
@@ -36,36 +38,60 @@ public class HttpClientHandler extends ChannelInboundHandlerAdapter { | @@ -36,36 +38,60 @@ public class HttpClientHandler extends ChannelInboundHandlerAdapter { | ||
36 | AttendanceService attendanceService = SpringContextHolder.getAttendanceService(); | 38 | AttendanceService attendanceService = SpringContextHolder.getAttendanceService(); |
37 | String content = (String) msg; | 39 | String content = (String) msg; |
38 | logger.info(content); | 40 | logger.info(content); |
41 | + //心跳 更新设备 | ||
39 | if (content.contains("/LAPI/V1.0/PACS/Controller/HeartReportInfo")) { | 42 | if (content.contains("/LAPI/V1.0/PACS/Controller/HeartReportInfo")) { |
40 | HeartInfo heartInfo = JSONObject.parseObject(getJson(content),HeartInfo.class); | 43 | HeartInfo heartInfo = JSONObject.parseObject(getJson(content),HeartInfo.class); |
41 | call.addChannel(heartInfo.getDeviceCode(),ctx); | 44 | call.addChannel(heartInfo.getDeviceCode(),ctx); |
42 | attendanceService.addAttendance(heartInfo.getDeviceCode()); | 45 | attendanceService.addAttendance(heartInfo.getDeviceCode()); |
43 | - } | ||
44 | - // 记录推送 | ||
45 | - if (content.contains("/LAPI/V1.0/System/Event/Notification/PersonVerification")) { | ||
46 | - String faceInfo = content.substring(content.indexOf("FaceInfoList")); | ||
47 | - String timeInfo = faceInfo.substring(faceInfo.indexOf("Timestamp")); | ||
48 | - String time = timeInfo.substring(11,timeInfo.indexOf(",")).trim(); | ||
49 | - String deviceString = content.substring(content.indexOf("DeviceCode")); | ||
50 | - String deviceCode = deviceString.substring(15,deviceString.indexOf(",")); | ||
51 | - deviceCode = deviceCode.substring(0,deviceCode.length()-1); | ||
52 | - call.setDeviceTime(deviceCode,time); | ||
53 | - }else if (StringUtils.contains(content, "Response")) { | ||
54 | - LAPIResponse lapiResponse = JSONObject.parseObject(content, LAPI.class).getResponse(); | ||
55 | - if(lapiResponse.getResponseUrl().equals(UrlParam.person_add)){ | ||
56 | - //人脸添加 | ||
57 | - call.putResponse(call.getDeviceCodeByChannel(ctx),lapiResponse); | 46 | + }else if (content.contains("Response")) { |
47 | + try{ | ||
48 | + LAPIResponse lapiResponse = JSONObject.parseObject(content.substring(content.indexOf("{")), LAPI.class).getResponse(); | ||
49 | + if(lapiResponse.getResponseUrl().equals(UrlParam.person_add)){ | ||
50 | + attendanceService.insertSend(lapiResponse,call.getDeviceCodeByChannel(ctx)); | ||
51 | + } | ||
52 | + }catch (Exception e){ | ||
58 | } | 53 | } |
59 | - }else if(content.contains("MatchPersonID")){ | ||
60 | - String personIdString = content.substring(content.indexOf("MatchPersonID")); | ||
61 | - String personId = personIdString.substring(15,personIdString.indexOf(",")).trim(); | 54 | + }else { |
62 | String deviceCode = call.getDeviceCodeByChannel(ctx); | 55 | String deviceCode = call.getDeviceCodeByChannel(ctx); |
63 | - String time = call.getDeviceTime(deviceCode); | ||
64 | - attendanceService.insertRecode(personId,deviceCode,time); | 56 | + if(content.contains("Content-Type")){ |
57 | + //第一个包-- 则对之前数据进行处理 | ||
58 | + StringBuffer data = call.getDeviceDataMap(deviceCode); | ||
59 | + handleData(attendanceService,deviceCode,data.toString()); | ||
60 | + //数据放入map中 | ||
61 | + data = new StringBuffer(); | ||
62 | + data.append(content); | ||
63 | + call.setDeviceDataMap(deviceCode,data); | ||
64 | + }else { | ||
65 | + //分包数据 连接 | ||
66 | + StringBuffer data = call.getDeviceDataMap(deviceCode); | ||
67 | + data.append(content); | ||
68 | + call.setDeviceDataMap(deviceCode,data); | ||
69 | + } | ||
65 | } | 70 | } |
66 | ctx.flush(); | 71 | ctx.flush(); |
67 | } | 72 | } |
68 | 73 | ||
74 | + public void handleData(AttendanceService attendanceService, | ||
75 | + String deviceCode , String data){ | ||
76 | + if (data.contains("/LAPI/V1.0/System/Event/Notification/PersonVerification")) { | ||
77 | + try{ | ||
78 | + data = data.substring(data.indexOf("{")); | ||
79 | + JSONObject object = JSONObject.parseObject(data); | ||
80 | + int timestamp = (Integer) object.get("Timestamp"); | ||
81 | + JSONArray faceInfoList = (JSONArray) object.get("FaceInfoList"); | ||
82 | + JSONObject faceInfo = faceInfoList.getJSONObject(0); | ||
83 | + BigDecimal temperature = (BigDecimal) faceInfo.get("Temperature"); | ||
84 | + JSONArray libMatInfoList = (JSONArray)object.get("LibMatInfoList"); | ||
85 | + JSONObject person = libMatInfoList.getJSONObject(0); | ||
86 | + int personId = (Integer) person.get("MatchPersonID") ; | ||
87 | + int userType = (Integer) person.get("MatchFaceID"); | ||
88 | + attendanceService.insertRecode(personId+"",deviceCode,timestamp+"000",temperature,userType); | ||
89 | + }catch (Exception e){ | ||
90 | + e.printStackTrace(); | ||
91 | + } | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
69 | public String getJson(String context){ | 95 | public String getJson(String context){ |
70 | String msg = context.substring(context.indexOf("{"),context.indexOf("}")+1); | 96 | String msg = context.substring(context.indexOf("{"),context.indexOf("}")+1); |
71 | return msg ; | 97 | return msg ; |
cloud/lapi/src/main/java/com/sincere/lapi/service/request/AttendanceService.java
1 | package com.sincere.lapi.service.request; | 1 | package com.sincere.lapi.service.request; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONArray; | ||
4 | +import com.alibaba.fastjson.JSONObject; | ||
5 | +import com.sincere.common.dto.smartCampus.CwStutemperaturereocrd; | ||
3 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | 6 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
4 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; | 7 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; |
5 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; | 8 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; |
6 | import com.sincere.common.dto.xiaoan.FaceRecoder; | 9 | import com.sincere.common.dto.xiaoan.FaceRecoder; |
10 | +import com.sincere.common.dto.xiaoan.FaceSendfail; | ||
11 | +import com.sincere.common.dto.xiaoan.FaceSendsuccess; | ||
7 | import com.sincere.common.util.DateUtils; | 12 | import com.sincere.common.util.DateUtils; |
8 | import com.sincere.lapi.feign.ScFeign; | 13 | import com.sincere.lapi.feign.ScFeign; |
9 | import com.sincere.lapi.feign.XaFeign; | 14 | import com.sincere.lapi.feign.XaFeign; |
15 | +import com.sincere.lapi.pojo.LAPIResponse; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
12 | 18 | ||
19 | +import java.math.BigDecimal; | ||
20 | +import java.util.HashMap; | ||
21 | +import java.util.Map; | ||
22 | + | ||
13 | @Service("attendanceService") | 23 | @Service("attendanceService") |
14 | public class AttendanceService { | 24 | public class AttendanceService { |
15 | 25 | ||
@@ -19,6 +29,20 @@ public class AttendanceService { | @@ -19,6 +29,20 @@ public class AttendanceService { | ||
19 | @Autowired | 29 | @Autowired |
20 | XaFeign xaFeign ; | 30 | XaFeign xaFeign ; |
21 | 31 | ||
32 | + private static Map<Integer,String> resultCodeMap = new HashMap<>(); | ||
33 | + | ||
34 | + static { | ||
35 | + resultCodeMap.put(1,"通用执行失败"); | ||
36 | + resultCodeMap.put(2,"初始化检测失败"); | ||
37 | + resultCodeMap.put(3,"人脸检测失败"); | ||
38 | + resultCodeMap.put(4,"图片未检测到人脸"); | ||
39 | + resultCodeMap.put(5,"jpeg 照片解码失败"); | ||
40 | + resultCodeMap.put(6,"人脸图片质量分数不满足"); | ||
41 | + resultCodeMap.put(7,"图片缩放失败"); | ||
42 | + resultCodeMap.put(8,"未启用智能"); | ||
43 | + resultCodeMap.put(9,"图片不存在或过大/过小"); | ||
44 | + } | ||
45 | + | ||
22 | public void addAttendance(String clientId){ | 46 | public void addAttendance(String clientId){ |
23 | SZ_AttendanceDto dto = new SZ_AttendanceDto(); | 47 | SZ_AttendanceDto dto = new SZ_AttendanceDto(); |
24 | dto.setClint_id(clientId); | 48 | dto.setClint_id(clientId); |
@@ -26,27 +50,106 @@ public class AttendanceService { | @@ -26,27 +50,106 @@ public class AttendanceService { | ||
26 | scFeign.addAttendance(dto); | 50 | scFeign.addAttendance(dto); |
27 | } | 51 | } |
28 | 52 | ||
29 | - | ||
30 | - public void insertRecode(String customerId , String deviceCode , String time){ | 53 | + public void insertRecode(String customerId , String deviceCode , String time , BigDecimal temperature ,int userType){ |
54 | + //1 老师 2 学生 | ||
31 | SZ_AttendanceDto attendanceDto = scFeign.selectAttendaceWithId(deviceCode); | 55 | SZ_AttendanceDto attendanceDto = scFeign.selectAttendaceWithId(deviceCode); |
32 | FaceRecoder faceRecoder = new FaceRecoder(); | 56 | FaceRecoder faceRecoder = new FaceRecoder(); |
33 | faceRecoder.setDeviceid(deviceCode); | 57 | faceRecoder.setDeviceid(deviceCode); |
34 | faceRecoder.setInorout(attendanceDto.getOutOrIn()); | 58 | faceRecoder.setInorout(attendanceDto.getOutOrIn()); |
35 | faceRecoder.setTime(DateUtils.getByLong(time)); | 59 | faceRecoder.setTime(DateUtils.getByLong(time)); |
36 | - SzVSchoolTeacher teacher = scFeign.selectByTeacherId(Integer.valueOf(customerId)); | ||
37 | - if(teacher == null){ | ||
38 | - SzVSchoolStudent student = scFeign.selectByStudentId(Integer.valueOf(customerId)); | ||
39 | - faceRecoder.setName(student.getName()); | ||
40 | - faceRecoder.setImgurl(student.getPhoto()); | ||
41 | - faceRecoder.setUserId(customerId); | ||
42 | - faceRecoder.setCardnum(student.getStudentNum()); | ||
43 | - }else { | 60 | + if(userType == 1){ |
61 | + SzVSchoolTeacher teacher = scFeign.selectByTeacherId(Integer.valueOf(customerId)); | ||
44 | faceRecoder.setCardnum(teacher.getTeacherNum()); | 62 | faceRecoder.setCardnum(teacher.getTeacherNum()); |
45 | faceRecoder.setUserId(customerId); | 63 | faceRecoder.setUserId(customerId); |
46 | faceRecoder.setImgurl(teacher.getFace()); | 64 | faceRecoder.setImgurl(teacher.getFace()); |
47 | faceRecoder.setName(teacher.getName()); | 65 | faceRecoder.setName(teacher.getName()); |
66 | + }else { | ||
67 | + SzVSchoolStudent student = scFeign.selectByStudentId(Integer.valueOf(customerId)); | ||
68 | + faceRecoder.setName(student.getName()); | ||
69 | + faceRecoder.setImgurl(student.getPhoto()); | ||
70 | + faceRecoder.setUserId(customerId); | ||
71 | + faceRecoder.setCardnum(student.getStudentNum()); | ||
72 | + CwStutemperaturereocrd record = new CwStutemperaturereocrd(); | ||
73 | + record.setClassid(student.getClassId()); | ||
74 | + record.setClassname(student.getClassName()); | ||
75 | + record.setIntime(DateUtils.getByLong(time)); | ||
76 | + record.setName(student.getName()); | ||
77 | + record.setStudentid(student.getStudentId()); | ||
78 | + record.setTemperature(temperature); | ||
79 | + record.setUserid(student.getUserId()); | ||
80 | + record.setSchoolid(student.getSchoolId()); | ||
81 | + scFeign.insertTemperature(record); | ||
48 | } | 82 | } |
49 | xaFeign.insertRecode(faceRecoder); | 83 | xaFeign.insertRecode(faceRecoder); |
50 | } | 84 | } |
51 | 85 | ||
86 | + public void insertSend(LAPIResponse response , String deviceCode){ | ||
87 | + try{ | ||
88 | + if(response.getStatusString().equals("Succeed")){ | ||
89 | + JSONObject data = JSONObject.parseObject(response.getData()); | ||
90 | + JSONArray personList = (JSONArray)data.get("PersonList") ; | ||
91 | + JSONObject person = (JSONObject)personList.get(0) ; | ||
92 | + int personId = (Integer) person.get("PersonID"); | ||
93 | + | ||
94 | + JSONArray faceList = (JSONArray) person.get("FaceList"); | ||
95 | + JSONObject face = (JSONObject) faceList.get(0); | ||
96 | + int code = (Integer) face.get("ResultCode") ; | ||
97 | + int userType = (Integer)face.get("FaceID"); | ||
98 | + String num , photo , name ; | ||
99 | + int schoolId ; | ||
100 | + if(userType == 1){ | ||
101 | + SzVSchoolTeacher teacher = scFeign.selectByTeacherId(personId); | ||
102 | + num = teacher.getTeacherNum(); | ||
103 | + photo = teacher.getFace(); | ||
104 | + name = teacher.getName(); | ||
105 | + schoolId = teacher.getSchoolId(); | ||
106 | + }else { | ||
107 | + SzVSchoolStudent student = scFeign.selectByStudentId(personId); | ||
108 | + num = student.getStudentNum(); | ||
109 | + photo = student.getPhoto() ; | ||
110 | + name = student.getName(); | ||
111 | + schoolId = student.getSchoolId(); | ||
112 | + } | ||
113 | + if(code == 0){ | ||
114 | + insertSuccess(deviceCode,personId,num,name,photo,schoolId,userType); | ||
115 | + }else { | ||
116 | + insertFail(deviceCode,personId,num,name,photo,schoolId,userType,code,resultCodeMap.get(code)); | ||
117 | + } | ||
118 | + }else { | ||
119 | + // insertFail(deviceCode,teacher.getTeacherId(),teacher.getTeacherNum(),teacher.getName(),teacher.getFace(),teacher.getSchoolId(),1,response.getStatusCode(),response.getStatusString()); | ||
120 | + } | ||
121 | + }catch (Exception e){ | ||
122 | + | ||
123 | + } | ||
124 | + | ||
125 | + } | ||
126 | + | ||
127 | + private void insertSuccess(String deviceId , int customerId , String num , String name , String imgPath , int schoolId ,int userType){ | ||
128 | + FaceSendsuccess send = new FaceSendsuccess(); | ||
129 | + send.setDeviceid(deviceId); | ||
130 | + send.setCustomerid(customerId+""); | ||
131 | + send.setDevicetype(25); | ||
132 | + send.setImgpath(imgPath); | ||
133 | + send.setSchoolid(schoolId); | ||
134 | + send.setUsertype(userType); | ||
135 | + send.setName(name); | ||
136 | + send.setNum(num); | ||
137 | + xaFeign.insertFaceSuccess(send); | ||
138 | + } | ||
139 | + | ||
140 | + private void insertFail(String deviceId , int customerId , String num , String name , String imgPath , int schoolId ,int userType , int failType ,String failContent){ | ||
141 | + FaceSendfail send = new FaceSendfail(); | ||
142 | + send.setDeviceid(deviceId); | ||
143 | + send.setCustomerid(customerId+""); | ||
144 | + send.setDevicetype(25); | ||
145 | + send.setImgpath(imgPath); | ||
146 | + send.setSchoolid(schoolId); | ||
147 | + send.setUsertype(userType); | ||
148 | + send.setName(name); | ||
149 | + send.setNum(num); | ||
150 | + send.setFailtype(failType); | ||
151 | + send.setFailcontent(failContent); | ||
152 | + xaFeign.insertFaceFail(send); | ||
153 | + } | ||
154 | + | ||
52 | } | 155 | } |
cloud/lapi/src/main/java/com/sincere/lapi/service/request/TerminalHttpCall.java
@@ -14,42 +14,31 @@ import java.net.URI; | @@ -14,42 +14,31 @@ import java.net.URI; | ||
14 | import java.util.Map; | 14 | import java.util.Map; |
15 | import java.util.concurrent.ConcurrentHashMap; | 15 | import java.util.concurrent.ConcurrentHashMap; |
16 | 16 | ||
17 | +/** | ||
18 | + * faceId == userType | ||
19 | + */ | ||
17 | @Component("terminalHttpCall") | 20 | @Component("terminalHttpCall") |
18 | public class TerminalHttpCall { | 21 | public class TerminalHttpCall { |
19 | 22 | ||
20 | 23 | ||
21 | //设备号 对应 通道 | 24 | //设备号 对应 通道 |
22 | private Map<String, ChannelHandlerContext> channelMap = new ConcurrentHashMap<String, ChannelHandlerContext>(); | 25 | private Map<String, ChannelHandlerContext> channelMap = new ConcurrentHashMap<String, ChannelHandlerContext>(); |
23 | - | ||
24 | //通道 对应 设备 | 26 | //通道 对应 设备 |
25 | private Map<ChannelHandlerContext , String> channelCodeMap = new ConcurrentHashMap<ChannelHandlerContext , String>(); | 27 | private Map<ChannelHandlerContext , String> channelCodeMap = new ConcurrentHashMap<ChannelHandlerContext , String>(); |
26 | - //key=deviceCode | ||
27 | - private Map<String , LAPIResponse> responseMap = new ConcurrentHashMap<>(); | ||
28 | - //设备刷脸时间 | ||
29 | - private Map<String,String> device2TimeMap = new ConcurrentHashMap<>(); | ||
30 | - | ||
31 | - public void setDeviceTime(String deviceCode , String time){ | ||
32 | - //给的是s 转ms | ||
33 | - device2TimeMap.put(deviceCode,time+"000"); | ||
34 | - } | ||
35 | - | ||
36 | - public String getDeviceTime(String deviceCode){ | ||
37 | - String time = device2TimeMap.get(deviceCode); | ||
38 | - device2TimeMap.remove(deviceCode); | ||
39 | - return time ; | ||
40 | - } | ||
41 | - | ||
42 | 28 | ||
43 | - public void putResponse(String key , LAPIResponse lapiResponse){ | ||
44 | - responseMap.put(key,lapiResponse); | ||
45 | - } | 29 | + //设备--上报数据 |
30 | + private Map<String,StringBuffer> deviceDataMap = new ConcurrentHashMap<>(); | ||
46 | 31 | ||
47 | - public LAPIResponse getResponse(String key){ | ||
48 | - return responseMap.get(key); | 32 | + public void setDeviceDataMap(String deviceCode , StringBuffer data){ |
33 | + deviceDataMap.put(deviceCode,data); | ||
49 | } | 34 | } |
50 | 35 | ||
51 | - public void removeKey(String key){ | ||
52 | - responseMap.remove(key); | 36 | + public StringBuffer getDeviceDataMap(String deviceCode){ |
37 | + StringBuffer data = deviceDataMap.get(deviceCode); | ||
38 | + if(data == null){ | ||
39 | + data = new StringBuffer(); | ||
40 | + } | ||
41 | + return data ; | ||
53 | } | 42 | } |
54 | 43 | ||
55 | public void addChannel(String deviceCode , ChannelHandlerContext channelHandlerContext){ | 44 | public void addChannel(String deviceCode , ChannelHandlerContext channelHandlerContext){ |
@@ -73,11 +62,6 @@ public class TerminalHttpCall { | @@ -73,11 +62,6 @@ public class TerminalHttpCall { | ||
73 | return add(deviceCode, UrlParam.person_add,personInfoList); | 62 | return add(deviceCode, UrlParam.person_add,personInfoList); |
74 | } | 63 | } |
75 | 64 | ||
76 | - public boolean keepAlive(String deviceCode){ | ||
77 | - return get(deviceCode,UrlParam.keep_alive); | ||
78 | - } | ||
79 | - | ||
80 | - | ||
81 | private <E> boolean put(String deviceCode , String prefixUrl) { | 65 | private <E> boolean put(String deviceCode , String prefixUrl) { |
82 | try { | 66 | try { |
83 | URI url = new URI(prefixUrl); | 67 | URI url = new URI(prefixUrl); |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/UserController.java
1 | package com.sincere.smartSearch.controller; | 1 | package com.sincere.smartSearch.controller; |
2 | 2 | ||
3 | +import com.sincere.common.dto.smartCampus.CwStutemperaturereocrd; | ||
3 | import com.sincere.common.dto.smartCampus.StudentBean; | 4 | import com.sincere.common.dto.smartCampus.StudentBean; |
4 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; | 5 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; |
5 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; | 6 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; |
6 | import com.sincere.smartSearch.service.UserService; | 7 | import com.sincere.smartSearch.service.UserService; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
8 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
9 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
10 | -import org.springframework.web.bind.annotation.RequestParam; | ||
11 | -import org.springframework.web.bind.annotation.RestController; | 9 | +import org.springframework.web.bind.annotation.*; |
12 | 10 | ||
13 | import java.util.List; | 11 | import java.util.List; |
14 | 12 | ||
@@ -24,6 +22,11 @@ public class UserController { | @@ -24,6 +22,11 @@ public class UserController { | ||
24 | @Autowired | 22 | @Autowired |
25 | UserService userService; | 23 | UserService userService; |
26 | 24 | ||
25 | + @RequestMapping(value = "insertTemperature",method = RequestMethod.POST) | ||
26 | + int insertTemperature(@RequestBody CwStutemperaturereocrd record){ | ||
27 | + return userService.insertTemperature(record); | ||
28 | + } | ||
29 | + | ||
27 | @RequestMapping(value = "selectStudentNumByStudentId",method = RequestMethod.GET) | 30 | @RequestMapping(value = "selectStudentNumByStudentId",method = RequestMethod.GET) |
28 | String selectStudentNumByStudentId(@RequestParam("studentId") int studentId){ | 31 | String selectStudentNumByStudentId(@RequestParam("studentId") int studentId){ |
29 | return userService.selectStudentNumByStudentId(studentId); | 32 | return userService.selectStudentNumByStudentId(studentId); |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/CwCheckMapper.java
0 → 100644
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +package com.sincere.smartSearch.mapper; | ||
2 | + | ||
3 | +import com.sincere.smartSearch.model.CwCheck; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public interface CwCheckMapper { | ||
8 | + | ||
9 | + List<CwCheck> selectBySchoolId(int schoolId); | ||
10 | +} | ||
0 | \ No newline at end of file | 11 | \ No newline at end of file |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/CwStutemperaturereocrdMapper.java
0 → 100644
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +package com.sincere.smartSearch.mapper; | ||
2 | + | ||
3 | +import com.sincere.common.dto.smartCampus.CwStutemperaturereocrd; | ||
4 | + | ||
5 | +public interface CwStutemperaturereocrdMapper { | ||
6 | + int insert(CwStutemperaturereocrd record); | ||
7 | + | ||
8 | + int insertSelective(CwStutemperaturereocrd record); | ||
9 | +} | ||
0 | \ No newline at end of file | 10 | \ No newline at end of file |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/model/CwCheck.java
0 → 100644
@@ -0,0 +1,85 @@ | @@ -0,0 +1,85 @@ | ||
1 | +package com.sincere.smartSearch.model; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | + | ||
5 | +public class CwCheck { | ||
6 | + private Integer id; | ||
7 | + | ||
8 | + private String checkname; | ||
9 | + | ||
10 | + private String begintime; | ||
11 | + | ||
12 | + private String endtime; | ||
13 | + | ||
14 | + private Integer templateid; | ||
15 | + | ||
16 | + private Integer schoolid; | ||
17 | + | ||
18 | + private Integer state; | ||
19 | + | ||
20 | + private Date intime; | ||
21 | + | ||
22 | + public Integer getId() { | ||
23 | + return id; | ||
24 | + } | ||
25 | + | ||
26 | + public void setId(Integer id) { | ||
27 | + this.id = id; | ||
28 | + } | ||
29 | + | ||
30 | + public String getCheckname() { | ||
31 | + return checkname; | ||
32 | + } | ||
33 | + | ||
34 | + public void setCheckname(String checkname) { | ||
35 | + this.checkname = checkname; | ||
36 | + } | ||
37 | + | ||
38 | + public String getBegintime() { | ||
39 | + return begintime; | ||
40 | + } | ||
41 | + | ||
42 | + public void setBegintime(String begintime) { | ||
43 | + this.begintime = begintime; | ||
44 | + } | ||
45 | + | ||
46 | + public String getEndtime() { | ||
47 | + return endtime; | ||
48 | + } | ||
49 | + | ||
50 | + public void setEndtime(String endtime) { | ||
51 | + this.endtime = endtime; | ||
52 | + } | ||
53 | + | ||
54 | + public Integer getTemplateid() { | ||
55 | + return templateid; | ||
56 | + } | ||
57 | + | ||
58 | + public void setTemplateid(Integer templateid) { | ||
59 | + this.templateid = templateid; | ||
60 | + } | ||
61 | + | ||
62 | + public Integer getSchoolid() { | ||
63 | + return schoolid; | ||
64 | + } | ||
65 | + | ||
66 | + public void setSchoolid(Integer schoolid) { | ||
67 | + this.schoolid = schoolid; | ||
68 | + } | ||
69 | + | ||
70 | + public Integer getState() { | ||
71 | + return state; | ||
72 | + } | ||
73 | + | ||
74 | + public void setState(Integer state) { | ||
75 | + this.state = state; | ||
76 | + } | ||
77 | + | ||
78 | + public Date getIntime() { | ||
79 | + return intime; | ||
80 | + } | ||
81 | + | ||
82 | + public void setIntime(Date intime) { | ||
83 | + this.intime = intime; | ||
84 | + } | ||
85 | +} | ||
0 | \ No newline at end of file | 86 | \ No newline at end of file |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/UserService.java
1 | package com.sincere.smartSearch.service; | 1 | package com.sincere.smartSearch.service; |
2 | 2 | ||
3 | +import com.sincere.common.dto.smartCampus.CwStutemperaturereocrd; | ||
3 | import com.sincere.common.dto.smartCampus.StudentBean; | 4 | import com.sincere.common.dto.smartCampus.StudentBean; |
4 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; | 5 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; |
5 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; | 6 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; |
@@ -27,4 +28,6 @@ public interface UserService { | @@ -27,4 +28,6 @@ public interface UserService { | ||
27 | 28 | ||
28 | SzVSchoolStudent selectByStudentId(int studentId); | 29 | SzVSchoolStudent selectByStudentId(int studentId); |
29 | 30 | ||
31 | + int insertTemperature(CwStutemperaturereocrd record); | ||
32 | + | ||
30 | } | 33 | } |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/UserServiceImpl.java
1 | package com.sincere.smartSearch.service.impl; | 1 | package com.sincere.smartSearch.service.impl; |
2 | 2 | ||
3 | +import com.sincere.common.dto.smartCampus.CwStutemperaturereocrd; | ||
3 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; | 4 | import com.sincere.common.dto.smartCampus.SzVSchoolStudent; |
4 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; | 5 | import com.sincere.common.dto.smartCampus.SzVSchoolTeacher; |
5 | -import com.sincere.smartSearch.mapper.SzVSchoolStudentMapper; | ||
6 | -import com.sincere.smartSearch.mapper.SzVSchoolTeacherMapper; | ||
7 | -import com.sincere.smartSearch.mapper.UserMapper; | 6 | +import com.sincere.common.util.DateUtils; |
7 | +import com.sincere.smartSearch.mapper.*; | ||
8 | import com.sincere.common.dto.smartCampus.StudentBean; | 8 | import com.sincere.common.dto.smartCampus.StudentBean; |
9 | +import com.sincere.smartSearch.model.CwCheck; | ||
9 | import com.sincere.smartSearch.service.UserService; | 10 | import com.sincere.smartSearch.service.UserService; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
12 | 13 | ||
14 | +import java.util.Date; | ||
13 | import java.util.List; | 15 | import java.util.List; |
14 | 16 | ||
15 | /** | 17 | /** |
@@ -29,6 +31,12 @@ public class UserServiceImpl implements UserService { | @@ -29,6 +31,12 @@ public class UserServiceImpl implements UserService { | ||
29 | @Autowired | 31 | @Autowired |
30 | SzVSchoolTeacherMapper szVSchoolTeacherMapper; | 32 | SzVSchoolTeacherMapper szVSchoolTeacherMapper; |
31 | 33 | ||
34 | + @Autowired | ||
35 | + CwStutemperaturereocrdMapper cwStutemperaturereocrdMapper ; | ||
36 | + | ||
37 | + @Autowired | ||
38 | + CwCheckMapper cwCheckMapper; | ||
39 | + | ||
32 | @Override | 40 | @Override |
33 | public String selectStudentNumByStudentId(int studentId) { | 41 | public String selectStudentNumByStudentId(int studentId) { |
34 | return userMapper.selectStudentNumByStudentId(studentId); | 42 | return userMapper.selectStudentNumByStudentId(studentId); |
@@ -65,4 +73,24 @@ public class UserServiceImpl implements UserService { | @@ -65,4 +73,24 @@ public class UserServiceImpl implements UserService { | ||
65 | public SzVSchoolStudent selectByStudentId(int studentId) { | 73 | public SzVSchoolStudent selectByStudentId(int studentId) { |
66 | return szVSchoolStudentMapper.selectByStudentId(studentId); | 74 | return szVSchoolStudentMapper.selectByStudentId(studentId); |
67 | } | 75 | } |
76 | + | ||
77 | + @Override | ||
78 | + public int insertTemperature(CwStutemperaturereocrd record) { | ||
79 | + List<CwCheck> list = cwCheckMapper.selectBySchoolId(record.getSchoolid()); | ||
80 | + try{ | ||
81 | + String today = DateUtils.getToday(DateUtils.format1); | ||
82 | + record.setType(1); | ||
83 | + for(CwCheck cwCheck : list){ | ||
84 | + Date begin = DateUtils.string2Date(today+cwCheck.getBegintime()+":00",DateUtils.format2); | ||
85 | + Date end = DateUtils.string2Date(today+cwCheck.getEndtime()+":00",DateUtils.format2); | ||
86 | + if(end.compareTo(record.getIntime()) > 1 && record.getIntime().compareTo(begin) > 1){ | ||
87 | + record.setType(cwCheck.getCheckname().equals("晨检")?1:2); | ||
88 | + } | ||
89 | + } | ||
90 | + return cwStutemperaturereocrdMapper.insert(record); | ||
91 | + }catch (Exception e){ | ||
92 | + | ||
93 | + } | ||
94 | + return 0 ; | ||
95 | + } | ||
68 | } | 96 | } |
cloud/search_smartCampus/src/main/resources/mapper/CwCheckMapper.xml
0 → 100644
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
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.CwCheckMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.sincere.smartSearch.model.CwCheck"> | ||
5 | + <result column="ID" jdbcType="INTEGER" property="id" /> | ||
6 | + <result column="CheckName" jdbcType="VARCHAR" property="checkname" /> | ||
7 | + <result column="BeginTime" jdbcType="VARCHAR" property="begintime" /> | ||
8 | + <result column="EndTime" jdbcType="VARCHAR" property="endtime" /> | ||
9 | + <result column="TemplateId" jdbcType="INTEGER" property="templateid" /> | ||
10 | + <result column="SchoolId" jdbcType="INTEGER" property="schoolid" /> | ||
11 | + <result column="State" jdbcType="INTEGER" property="state" /> | ||
12 | + <result column="Intime" jdbcType="TIMESTAMP" property="intime" /> | ||
13 | + </resultMap> | ||
14 | + | ||
15 | + <select id="selectBySchoolId" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | ||
16 | + select * from CW_Check where SchoolId =#{schoolId} and state = 1 | ||
17 | + </select> | ||
18 | +</mapper> | ||
0 | \ No newline at end of file | 19 | \ No newline at end of file |
cloud/search_smartCampus/src/main/resources/mapper/CwStutemperaturereocrdMapper.xml
0 → 100644
@@ -0,0 +1,93 @@ | @@ -0,0 +1,93 @@ | ||
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.CwStutemperaturereocrdMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.sincere.common.dto.smartCampus.CwStutemperaturereocrd"> | ||
5 | + <result column="Id" jdbcType="INTEGER" property="id" /> | ||
6 | + <result column="UserId" jdbcType="VARCHAR" property="userid" /> | ||
7 | + <result column="StudentId" jdbcType="INTEGER" property="studentid" /> | ||
8 | + <result column="Name" jdbcType="VARCHAR" property="name" /> | ||
9 | + <result column="ClassId" jdbcType="INTEGER" property="classid" /> | ||
10 | + <result column="ClassName" jdbcType="VARCHAR" property="classname" /> | ||
11 | + <result column="Temperature" jdbcType="DECIMAL" property="temperature" /> | ||
12 | + <result column="Type" jdbcType="INTEGER" property="type" /> | ||
13 | + <result column="SchoolId" jdbcType="INTEGER" property="schoolid" /> | ||
14 | + <result column="Intime" jdbcType="TIMESTAMP" property="intime" /> | ||
15 | + </resultMap> | ||
16 | + <insert id="insert" parameterType="com.sincere.common.dto.smartCampus.CwStutemperaturereocrd"> | ||
17 | + insert into CW_StuTemperatureReocrd ( UserId, StudentId, | ||
18 | + Name, ClassId, ClassName, | ||
19 | + Temperature, Type, SchoolId, | ||
20 | + Intime) | ||
21 | + values ( #{userid,jdbcType=VARCHAR}, #{studentid,jdbcType=INTEGER}, | ||
22 | + #{name,jdbcType=VARCHAR}, #{classid,jdbcType=INTEGER}, #{classname,jdbcType=VARCHAR}, | ||
23 | + #{temperature,jdbcType=DECIMAL}, #{type,jdbcType=INTEGER}, #{schoolid,jdbcType=INTEGER}, | ||
24 | + #{intime,jdbcType=TIMESTAMP}) | ||
25 | + </insert> | ||
26 | + <insert id="insertSelective" parameterType="com.sincere.common.dto.smartCampus.CwStutemperaturereocrd"> | ||
27 | + insert into CW_StuTemperatureReocrd | ||
28 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
29 | + <if test="id != null"> | ||
30 | + Id, | ||
31 | + </if> | ||
32 | + <if test="userid != null"> | ||
33 | + UserId, | ||
34 | + </if> | ||
35 | + <if test="studentid != null"> | ||
36 | + StudentId, | ||
37 | + </if> | ||
38 | + <if test="name != null"> | ||
39 | + Name, | ||
40 | + </if> | ||
41 | + <if test="classid != null"> | ||
42 | + ClassId, | ||
43 | + </if> | ||
44 | + <if test="classname != null"> | ||
45 | + ClassName, | ||
46 | + </if> | ||
47 | + <if test="temperature != null"> | ||
48 | + Temperature, | ||
49 | + </if> | ||
50 | + <if test="type != null"> | ||
51 | + Type, | ||
52 | + </if> | ||
53 | + <if test="schoolid != null"> | ||
54 | + SchoolId, | ||
55 | + </if> | ||
56 | + <if test="intime != null"> | ||
57 | + Intime, | ||
58 | + </if> | ||
59 | + </trim> | ||
60 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
61 | + <if test="id != null"> | ||
62 | + #{id,jdbcType=INTEGER}, | ||
63 | + </if> | ||
64 | + <if test="userid != null"> | ||
65 | + #{userid,jdbcType=VARCHAR}, | ||
66 | + </if> | ||
67 | + <if test="studentid != null"> | ||
68 | + #{studentid,jdbcType=INTEGER}, | ||
69 | + </if> | ||
70 | + <if test="name != null"> | ||
71 | + #{name,jdbcType=VARCHAR}, | ||
72 | + </if> | ||
73 | + <if test="classid != null"> | ||
74 | + #{classid,jdbcType=INTEGER}, | ||
75 | + </if> | ||
76 | + <if test="classname != null"> | ||
77 | + #{classname,jdbcType=VARCHAR}, | ||
78 | + </if> | ||
79 | + <if test="temperature != null"> | ||
80 | + #{temperature,jdbcType=DECIMAL}, | ||
81 | + </if> | ||
82 | + <if test="type != null"> | ||
83 | + #{type,jdbcType=INTEGER}, | ||
84 | + </if> | ||
85 | + <if test="schoolid != null"> | ||
86 | + #{schoolid,jdbcType=INTEGER}, | ||
87 | + </if> | ||
88 | + <if test="intime != null"> | ||
89 | + #{intime,jdbcType=TIMESTAMP}, | ||
90 | + </if> | ||
91 | + </trim> | ||
92 | + </insert> | ||
93 | +</mapper> | ||
0 | \ No newline at end of file | 94 | \ No newline at end of file |