Commit aceb80c1341e6e827311f1cce3cad7f744881bac
1 parent
5556ee02
Exists in
master
机器人接口对接完成
Showing
12 changed files
with
475 additions
and
23 deletions
Show diff stats
springboot/morning-check/pom.xml
springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/CheckReportController.java
1 | 1 | package com.sincere.morningcheck.controller; |
2 | 2 | |
3 | 3 | import com.sincere.morningcheck.common.ServerResponse; |
4 | +import com.sincere.morningcheck.model.ApiStudent; | |
4 | 5 | import com.sincere.morningcheck.model.ApiStudentCheckReport; |
5 | 6 | import com.sincere.morningcheck.service.StudentCheckReportService; |
7 | +import com.sincere.morningcheck.utils.ExcelUtils; | |
6 | 8 | import io.swagger.annotations.Api; |
7 | 9 | import io.swagger.annotations.ApiImplicitParam; |
8 | 10 | import io.swagger.annotations.ApiImplicitParams; |
9 | 11 | import io.swagger.annotations.ApiOperation; |
10 | 12 | |
13 | +import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
11 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
12 | 15 | import org.springframework.web.bind.annotation.GetMapping; |
13 | 16 | import org.springframework.web.bind.annotation.RequestMapping; |
14 | 17 | import org.springframework.web.bind.annotation.RequestParam; |
15 | 18 | import org.springframework.web.bind.annotation.RestController; |
16 | 19 | |
20 | +import javax.servlet.http.HttpServletResponse; | |
21 | +import java.util.ArrayList; | |
22 | +import java.util.List; | |
23 | + | |
17 | 24 | |
18 | 25 | @RestController |
19 | 26 | @RequestMapping("check_report") |
... | ... | @@ -48,9 +55,129 @@ public class CheckReportController { |
48 | 55 | @ApiImplicitParam(name = "gradeId",value = "年级标识",required = true) |
49 | 56 | }) |
50 | 57 | @GetMapping("getCheckExReportByGrade") |
51 | - public ServerResponse getCheckExReportByGrade(@RequestParam Integer schoolId,@RequestParam Integer gradeId){ | |
58 | + public ServerResponse getCheckExReportByGrade(@RequestParam Integer schoolId,@RequestParam Integer gradeId,@RequestParam String checkTime){ | |
59 | + | |
60 | + return studentCheckReportService.getCheckExReportByGrade(schoolId,gradeId,checkTime); | |
61 | + } | |
62 | + | |
63 | + @ApiOperation(value = "学生晨检报告报表") | |
64 | + @ApiImplicitParams({ | |
65 | + @ApiImplicitParam(name = "schoolId",value = "学校ID",required = true), | |
66 | + @ApiImplicitParam(name = "checkTime",value = "检查报告的时间,格式为yyyy-MM-dd",required = true), | |
67 | + @ApiImplicitParam(name = "gradeId",value = "年级ID",defaultValue = "0") | |
68 | + }) | |
69 | + @GetMapping("getCheckReportData") | |
70 | + public ServerResponse getCheckReportData(@RequestParam Integer schoolId,@RequestParam String checkTime,@RequestParam(name = "gradeId",required = false) Integer gradeId){ | |
52 | 71 | |
53 | - return studentCheckReportService.getCheckExReportByGrade(schoolId,gradeId); | |
72 | + return studentCheckReportService.getCheckReportData(schoolId,checkTime,gradeId); | |
54 | 73 | } |
55 | 74 | |
75 | + | |
76 | + @ApiOperation("导出报表") | |
77 | + @ApiImplicitParams({ | |
78 | + @ApiImplicitParam(name = "schoolId",value = "学校ID",required = true), | |
79 | + @ApiImplicitParam(name = "checkTime",value = "检查报告的时间,格式为yyyy-MM-dd",required = true), | |
80 | + @ApiImplicitParam(name = "gradeId",value = "年级ID",defaultValue = "0") | |
81 | + }) | |
82 | + @GetMapping("excelCheckReportData") | |
83 | + public void excelCheckReportData(HttpServletResponse response, @RequestParam Integer schoolId, @RequestParam String checkTime,@RequestParam(name = "gradeId",required = false) Integer gradeId){ | |
84 | + | |
85 | + //查询出需要导出的数据 | |
86 | + List<ApiStudent> apiStudentList=studentCheckReportService.getCheckReportData(schoolId,checkTime,gradeId).getData(); | |
87 | + //创建报表数据头 | |
88 | + List<String> head = new ArrayList<>(); | |
89 | + head.add("姓名"); | |
90 | + head.add("班级"); | |
91 | + head.add("入园时间"); | |
92 | + head.add("手检"); | |
93 | + head.add("眼检"); | |
94 | + head.add("口腔"); | |
95 | + head.add("喉咙"); | |
96 | + head.add("体温"); | |
97 | + head.add("腮部"); | |
98 | + head.add("外表"); | |
99 | + head.add("外伤情况"); | |
100 | + head.add("指甲"); | |
101 | + head.add("牙齿"); | |
102 | + head.add("其他"); | |
103 | + head.add("处理情况"); | |
104 | + //创建报表体 | |
105 | + List<List<String>> body = new ArrayList<>();//模拟二维集合 | |
106 | + if(apiStudentList!=null) { | |
107 | + for (ApiStudent stu : apiStudentList) { | |
108 | + List<String> bodyValue = new ArrayList<>(); | |
109 | + bodyValue.add(String.valueOf(stu.getStuName())); | |
110 | + bodyValue.add(stu.getClassName()); | |
111 | + bodyValue.add(String.valueOf(stu.getCheckTime())); | |
112 | + if (stu.getCheckResultObj().getHandNoEx()) { | |
113 | + bodyValue.add("正常"); | |
114 | + } else { | |
115 | + bodyValue.add("异常cellStyle"); | |
116 | + } | |
117 | + if (stu.getCheckResultObj().getNoRedEye()) { | |
118 | + bodyValue.add("正常"); | |
119 | + } else { | |
120 | + bodyValue.add("红眼cellStyle"); | |
121 | + } | |
122 | + if (stu.getCheckResultObj().getMouthNoEx()) { | |
123 | + bodyValue.add("正常"); | |
124 | + } else { | |
125 | + bodyValue.add("异常cellStyle"); | |
126 | + } | |
127 | + if (stu.getCheckResultObj().getNoPharyngitis()&&stu.getCheckResultObj().getNoCough()) { | |
128 | + bodyValue.add("正常"); | |
129 | + } else { | |
130 | + String desc = ""; | |
131 | + if(!stu.getCheckResultObj().getNoPharyngitis()){ | |
132 | + desc = desc + "咽炎、" ; | |
133 | + } | |
134 | + if(!stu.getCheckResultObj().getNoCough()){ | |
135 | + desc = desc + "咳嗽" ; | |
136 | + } | |
137 | + bodyValue.add(desc+"cellStyle"); | |
138 | + } | |
139 | + if (stu.getCheckResultObj().getNoFever()) { | |
140 | + bodyValue.add("正常"); | |
141 | + } else { | |
142 | + bodyValue.add("发烧cellStyle"); | |
143 | + } | |
144 | + if (stu.getCheckResultObj().getNoCrotchBig()) { | |
145 | + bodyValue.add("正常"); | |
146 | + } else { | |
147 | + bodyValue.add("腮部肿大cellStyle"); | |
148 | + } | |
149 | + if (stu.getCheckResultObj().getNoPoorSpirit()) { | |
150 | + bodyValue.add("正常"); | |
151 | + } else { | |
152 | + bodyValue.add("精神不佳cellStyle"); | |
153 | + } | |
154 | + if (stu.getCheckResultObj().getNoTrauma()) { | |
155 | + bodyValue.add("正常"); | |
156 | + } else { | |
157 | + bodyValue.add("外伤cellStyle"); | |
158 | + } | |
159 | + if (stu.getCheckResultObj().getNoNail()) { | |
160 | + bodyValue.add("正常"); | |
161 | + } else { | |
162 | + bodyValue.add("过长cellStyle"); | |
163 | + } | |
164 | + if (stu.getCheckResultObj().getNoToothDecay()) { | |
165 | + bodyValue.add("正常"); | |
166 | + } else { | |
167 | + bodyValue.add("蛀牙cellStyle"); | |
168 | + } | |
169 | + if (stu.getCheckResultObj().getOther()) { | |
170 | + bodyValue.add("正常"); | |
171 | + } else { | |
172 | + bodyValue.add("异常cellStyle"); | |
173 | + } | |
174 | + bodyValue.add(""); | |
175 | + //将数据添加到报表体中 | |
176 | + body.add(bodyValue); | |
177 | + } | |
178 | + } | |
179 | + String fileName = checkTime+"_学生晨检报告.xls"; | |
180 | + HSSFWorkbook excel = ExcelUtils.expExcel(head,body); | |
181 | + ExcelUtils.outFileStream(excel,fileName,response); | |
182 | + } | |
56 | 183 | } | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java
... | ... | @@ -3,10 +3,7 @@ package com.sincere.morningcheck.controller; |
3 | 3 | import com.sincere.morningcheck.common.EhcacheUtil; |
4 | 4 | import com.sincere.morningcheck.common.MD5; |
5 | 5 | import com.sincere.morningcheck.common.ServerResponse; |
6 | -import com.sincere.morningcheck.model.School; | |
7 | -import com.sincere.morningcheck.model.Student; | |
8 | -import com.sincere.morningcheck.model.StudentCheckReport; | |
9 | -import com.sincere.morningcheck.model.User; | |
6 | +import com.sincere.morningcheck.model.*; | |
10 | 7 | import com.sincere.morningcheck.service.FileUpAndDownService; |
11 | 8 | import com.sincere.morningcheck.service.StudentCheckReportService; |
12 | 9 | import com.sincere.morningcheck.service.StudentService; |
... | ... | @@ -366,7 +363,6 @@ public class MorningCheckController { |
366 | 363 | studentCheckReport.setCardNo(card); |
367 | 364 | studentCheckReport.setCheckResult(result); |
368 | 365 | studentCheckReport.setRobotResult(robotResult); |
369 | - //java.sql.Date checkDate = new java.sql.Date(new Date().getTime()); | |
370 | 366 | Date checkDate = new Date(); |
371 | 367 | studentCheckReport.setCheckTime(checkDate); |
372 | 368 | studentCheckReport.setInTime(checkDate); |
... | ... | @@ -379,8 +375,29 @@ public class MorningCheckController { |
379 | 375 | Student student = studentService.getStudentByCardNo(card); |
380 | 376 | String msg = String.format("学生%s你好,你的晨检报告已经自动生成",student.getStuName()); |
381 | 377 | studentCheckReport.setStudent_id(student.getStuId()); |
382 | - studentCheckReportService.insert(studentCheckReport); | |
383 | 378 | |
379 | + StudentCheckReport studentCheckReportEntity= studentCheckReportService.getCheckReport(student.getStuId()); | |
380 | + if(studentCheckReportEntity==null){ | |
381 | + studentCheckReportService.insert(studentCheckReport); | |
382 | + }else{ | |
383 | + studentCheckReport.setId(studentCheckReportEntity.getId()); | |
384 | + int updateCount = studentCheckReportService.updateByStudent(studentCheckReport); | |
385 | + } | |
386 | + | |
387 | + StudentCheckReportHis studentCheckReportHis = new StudentCheckReportHis(); | |
388 | + studentCheckReportHis.setAccess(studentCheckReport.getAccess()); | |
389 | + studentCheckReportHis.setCardNo(studentCheckReport.getCardNo()); | |
390 | + studentCheckReportHis.setCheck_id(studentCheckReport.getId()); | |
391 | + studentCheckReportHis.setCheckResult(studentCheckReport.getCheckResult()); | |
392 | + studentCheckReportHis.setRobotResult(studentCheckReport.getRobotResult()); | |
393 | + studentCheckReportHis.setInTime(studentCheckReport.getInTime()); | |
394 | + studentCheckReportHis.setCheckTime(studentCheckReport.getCheckTime()); | |
395 | + studentCheckReportHis.setTemperature(studentCheckReport.getTemperature()); | |
396 | + studentCheckReportHis.setEyeImgId(studentCheckReport.getEyeImgId()); | |
397 | + studentCheckReportHis.setHandImgId(studentCheckReport.getHandImgId()); | |
398 | + studentCheckReportHis.setMouthImgId(studentCheckReport.getMouthImgId()); | |
399 | + studentCheckReportHis.setStudent_id(studentCheckReport.getStudent_id()); | |
400 | + studentCheckReportService.insertCheckHis(studentCheckReportHis); | |
384 | 401 | serverResponse = ServerResponse.createBySuccessMessage(msg); |
385 | 402 | }else{ |
386 | 403 | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentCheckReportDao.java
... | ... | @@ -2,6 +2,7 @@ package com.sincere.morningcheck.dao; |
2 | 2 | |
3 | 3 | import com.sincere.morningcheck.model.ClassExReport; |
4 | 4 | import com.sincere.morningcheck.model.StudentCheckReport; |
5 | +import com.sincere.morningcheck.model.StudentCheckReportHis; | |
5 | 6 | import org.apache.ibatis.annotations.Mapper; |
6 | 7 | import org.apache.ibatis.annotations.Param; |
7 | 8 | import org.springframework.stereotype.Repository; |
... | ... | @@ -14,11 +15,20 @@ public interface StudentCheckReportDao { |
14 | 15 | |
15 | 16 | int insert(StudentCheckReport studentCheckReport); |
16 | 17 | |
18 | + int insertCheckHis(StudentCheckReportHis studentCheckReportHis); | |
19 | + | |
20 | + /** | |
21 | + * 根据卡号和学生标识修改学生检查报告信息 | |
22 | + * @param studentCheckReport | |
23 | + * @return | |
24 | + */ | |
25 | + int updateByStudent(StudentCheckReport studentCheckReport); | |
26 | + | |
17 | 27 | List<StudentCheckReport> getCheckReport(@Param("studentId") Integer studentId); |
18 | 28 | |
19 | 29 | int getCheckStuCountBySchoolId(@Param("schoolId")Integer schoolId,@Param("checkTime") String checkTime); |
20 | 30 | |
21 | 31 | List<StudentCheckReport> getCheckReportBySchoolId(@Param("schoolId")Integer schoolId,@Param("checkTime") String checkTime); |
22 | 32 | |
23 | - List<ClassExReport> getCheckExReportByGrade(@Param("schoolId")Integer schoolId,@Param("gradeId") Integer gradeId); | |
33 | + List<ClassExReport> getCheckExReportByGrade(@Param("schoolId")Integer schoolId,@Param("gradeId") Integer gradeId,@Param("checkTime") String checkTime); | |
24 | 34 | } | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/ApiStudent.java
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +package com.sincere.morningcheck.model; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +@Data | |
6 | +/** | |
7 | + * 用于报表导出 | |
8 | + */ | |
9 | +public class ApiStudent extends ApiStudentCheckReport { | |
10 | + private Integer classId; | |
11 | + private String stuName; | |
12 | + private String className; | |
13 | + | |
14 | +} | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/CheckResult.java
... | ... | @@ -38,7 +38,7 @@ public class CheckResult { |
38 | 38 | @ApiModelProperty(name = "noCough",value = "08,true正常,false咳嗽") |
39 | 39 | private Boolean noCough; |
40 | 40 | |
41 | - @ApiModelProperty(name = "noNail",value = "09,true正常,false过长") | |
41 | + @ApiModelProperty(name = "noNail",value = "09,true正常,false指甲过长") | |
42 | 42 | private Boolean noNail; |
43 | 43 | |
44 | 44 | @ApiModelProperty(name = "noToothDecay",value = "10,true正常,false蛀牙") | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/ClassExReport.java
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/StudentCheckReportHis.java
0 → 100644
... | ... | @@ -0,0 +1,46 @@ |
1 | +package com.sincere.morningcheck.model; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.util.Date; | |
6 | + | |
7 | +@Data | |
8 | +/** | |
9 | + * 检查报告历史记录表 | |
10 | + */ | |
11 | +public class StudentCheckReportHis { | |
12 | + private Integer id; | |
13 | + | |
14 | + /** | |
15 | + * 检查报告表ID | |
16 | + */ | |
17 | + private Integer check_id; | |
18 | + | |
19 | + private Integer student_id; | |
20 | + | |
21 | + private String cardNo; | |
22 | + | |
23 | + /** | |
24 | + * 人为判别结果 | |
25 | + */ | |
26 | + private String checkResult; //json字符串 | |
27 | + | |
28 | + /** | |
29 | + * 机器判别结果 | |
30 | + */ | |
31 | + private String robotResult; //json字符串 | |
32 | + | |
33 | + private Date checkTime; | |
34 | + | |
35 | + private Date inTime; | |
36 | + | |
37 | + private String access; | |
38 | + | |
39 | + private String temperature; | |
40 | + | |
41 | + private String handImgId; | |
42 | + | |
43 | + private String mouthImgId; | |
44 | + | |
45 | + private String eyeImgId; | |
46 | +} | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentCheckReportService.java
... | ... | @@ -2,16 +2,33 @@ package com.sincere.morningcheck.service; |
2 | 2 | |
3 | 3 | |
4 | 4 | import com.sincere.morningcheck.common.ServerResponse; |
5 | +import com.sincere.morningcheck.model.ApiStudent; | |
5 | 6 | import com.sincere.morningcheck.model.ApiStudentCheckReport; |
6 | 7 | import com.sincere.morningcheck.model.StudentCheckReport; |
8 | +import com.sincere.morningcheck.model.StudentCheckReportHis; | |
9 | + | |
10 | +import java.util.List; | |
7 | 11 | |
8 | 12 | public interface StudentCheckReportService { |
9 | 13 | |
10 | 14 | int insert(StudentCheckReport studentCheckReport); |
11 | 15 | |
16 | + int insertCheckHis(StudentCheckReportHis studentCheckReportHis); | |
17 | + | |
18 | + /** | |
19 | + * 根据卡号和学生标识修改学生检查报告信息 | |
20 | + * @param studentCheckReport | |
21 | + * @return | |
22 | + */ | |
23 | + int updateByStudent(StudentCheckReport studentCheckReport); | |
24 | + | |
25 | + StudentCheckReport getCheckReport(Integer studentId); | |
26 | + | |
12 | 27 | ServerResponse<ApiStudentCheckReport> getCheckReport(String stuUserId); |
13 | 28 | |
14 | 29 | ServerResponse getCheckReportBySchool(Integer schoolId,String checkTime); |
15 | 30 | |
16 | - ServerResponse getCheckExReportByGrade(Integer schoolId,Integer gradeId); | |
31 | + ServerResponse getCheckExReportByGrade(Integer schoolId,Integer gradeId,String checkTime); | |
32 | + | |
33 | + ServerResponse<List<ApiStudent>> getCheckReportData(Integer schoolId, String checkTime,int gradeId); | |
17 | 34 | } | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentCheckReportServiceImpl.java
... | ... | @@ -5,6 +5,7 @@ import com.sincere.morningcheck.dao.StudentCheckReportDao; |
5 | 5 | import com.sincere.morningcheck.dao.StudentDao; |
6 | 6 | import com.sincere.morningcheck.model.*; |
7 | 7 | import com.sincere.morningcheck.service.StudentCheckReportService; |
8 | +import org.apache.commons.lang3.StringUtils; | |
8 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
9 | 10 | import org.springframework.stereotype.Service; |
10 | 11 | |
... | ... | @@ -27,6 +28,25 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
27 | 28 | } |
28 | 29 | |
29 | 30 | @Override |
31 | + public int insertCheckHis(StudentCheckReportHis studentCheckReportHis) { | |
32 | + return studentCheckReportDao.insertCheckHis(studentCheckReportHis); | |
33 | + } | |
34 | + | |
35 | + @Override | |
36 | + public int updateByStudent(StudentCheckReport studentCheckReport) { | |
37 | + return studentCheckReportDao.updateByStudent(studentCheckReport); | |
38 | + } | |
39 | + | |
40 | + @Override | |
41 | + public StudentCheckReport getCheckReport(Integer studentId) { | |
42 | + List<StudentCheckReport> studentCheckReports = studentCheckReportDao.getCheckReport(studentId); | |
43 | + if(studentCheckReports!=null&&studentCheckReports.size()>0){ | |
44 | + return studentCheckReports.get(0); | |
45 | + } | |
46 | + return null; | |
47 | + } | |
48 | + | |
49 | + @Override | |
30 | 50 | public ServerResponse<ApiStudentCheckReport> getCheckReport(String stuUserId) { |
31 | 51 | |
32 | 52 | List<StudentCheckReport> studentCheckReports = new ArrayList<>(); |
... | ... | @@ -160,9 +180,9 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
160 | 180 | } |
161 | 181 | |
162 | 182 | @Override |
163 | - public ServerResponse getCheckExReportByGrade(Integer schoolId, Integer gradeId) { | |
183 | + public ServerResponse getCheckExReportByGrade(Integer schoolId, Integer gradeId,String checkTime) { | |
164 | 184 | |
165 | - List<ClassExReport> classExReports = studentCheckReportDao.getCheckExReportByGrade(schoolId,gradeId); | |
185 | + List<ClassExReport> classExReports = studentCheckReportDao.getCheckExReportByGrade(schoolId,gradeId,checkTime); | |
166 | 186 | float count = 0; |
167 | 187 | for(ClassExReport classExReport : classExReports){ |
168 | 188 | count = count + classExReport.getCount(); |
... | ... | @@ -170,7 +190,7 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
170 | 190 | |
171 | 191 | if(count>0){ |
172 | 192 | for(ClassExReport classExReport : classExReports){ |
173 | - classExReport.setExRate((classExReport.getCount()/count)*100); | |
193 | + classExReport.setValue((classExReport.getCount()/count)*100); | |
174 | 194 | } |
175 | 195 | }else { |
176 | 196 | return ServerResponse.createByErrorCodeMessage(10,"暂无数据"); |
... | ... | @@ -178,6 +198,39 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
178 | 198 | return ServerResponse.createBySuccess(classExReports); |
179 | 199 | } |
180 | 200 | |
201 | + @Override | |
202 | + public ServerResponse<List<ApiStudent>> getCheckReportData(Integer schoolId, String checkTime,int gradeId) { | |
203 | + List<StudentCheckReport> studentCheckReports = studentCheckReportDao.getCheckReportBySchoolId(schoolId,checkTime); | |
204 | + | |
205 | + List<ApiStudent> apiStudents = new ArrayList<>(); | |
206 | + for(StudentCheckReport item : studentCheckReports){ | |
207 | + ApiStudent apiStudent = new ApiStudent(); | |
208 | + apiStudent.setCardNo(item.getCardNo()); | |
209 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm"); | |
210 | + apiStudent.setCheckTime(simpleDateFormat.format(item.getCheckTime())); | |
211 | + apiStudent.setTemperature(item.getTemperature()); | |
212 | + if(StringUtils.isNotBlank(item.getCheckResult())){ | |
213 | + char[] chs = item.getCheckResult().toCharArray(); | |
214 | + apiStudent.setCheckResultObj(getCheckResult(chs)); | |
215 | + } | |
216 | + if(StringUtils.isNotBlank(item.getCardNo())){ | |
217 | + Student student = studentDao.getStudentByCardNo(item.getCardNo()); | |
218 | + apiStudent.setClassName(student.getClassName()); | |
219 | + apiStudent.setStudent_id(student.getStuId()); | |
220 | + apiStudent.setStuName(student.getStuName()); | |
221 | + apiStudent.setClassId(student.getClassId()); | |
222 | + } | |
223 | + apiStudents.add(apiStudent); | |
224 | + } | |
225 | + if(gradeId>0) { | |
226 | + apiStudents = apiStudents.stream().filter(n -> n.getClassId() == gradeId).collect(Collectors.toList()); | |
227 | + } | |
228 | + if(apiStudents.size()<=0){ | |
229 | + return ServerResponse.createByErrorCodeMessage(10,"暂无数据"); | |
230 | + } | |
231 | + return ServerResponse.createBySuccess(apiStudents); | |
232 | + } | |
233 | + | |
181 | 234 | private ApiStudentCheckReport getApiStudentReport(StudentCheckReport studentCheckReport,Boolean isMorningCheck){ |
182 | 235 | |
183 | 236 | ApiStudentCheckReport apiStudentCheckReport = new ApiStudentCheckReport(); | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ExcelUtils.java
0 → 100644
... | ... | @@ -0,0 +1,149 @@ |
1 | +package com.sincere.morningcheck.utils; | |
2 | + | |
3 | +import org.apache.poi.hssf.usermodel.*; | |
4 | +import org.apache.poi.ss.usermodel.BorderStyle; | |
5 | +import org.apache.poi.ss.usermodel.FillPatternType; | |
6 | +import org.apache.poi.ss.usermodel.IndexedColors; | |
7 | + | |
8 | +import javax.servlet.http.HttpServletResponse; | |
9 | +import java.io.*; | |
10 | +import java.net.URLEncoder; | |
11 | +import java.text.SimpleDateFormat; | |
12 | +import java.util.Date; | |
13 | +import java.util.List; | |
14 | + | |
15 | +public class ExcelUtils { | |
16 | + | |
17 | + static final BorderStyle borderpx = BorderStyle.THIN; | |
18 | + | |
19 | + /** | |
20 | + * 导出excel表格 | |
21 | + * @param head | |
22 | + * @param body | |
23 | + * @return | |
24 | + */ | |
25 | + public static HSSFWorkbook expExcel(List<String> head, List<List<String>> body) { | |
26 | + HSSFWorkbook workbook = new HSSFWorkbook(); | |
27 | + HSSFSheet sheet = workbook.createSheet("Sheet1"); | |
28 | + HSSFRow row = sheet.createRow(0); | |
29 | + HSSFCell cell= null; | |
30 | + HSSFCellStyle cellStyle = workbook.createCellStyle(); | |
31 | + setBorderStyle(cellStyle, borderpx); | |
32 | + cellStyle.setFont(setFontStyle(workbook, "黑体", (short) 14)); | |
33 | + sheet.createFreezePane(0,1,0,1); | |
34 | + | |
35 | + for (int i = 0; i<head.size(); i++) { | |
36 | + cell = row.createCell(i); | |
37 | + cell.setCellValue(head.get(i)); | |
38 | + cell.setCellStyle(cellStyle); | |
39 | + } | |
40 | + | |
41 | + HSSFCellStyle cellStyle2 = workbook.createCellStyle(); | |
42 | + HSSFCellStyle cellStyleEx = workbook.createCellStyle(); | |
43 | + setBorderStyle(cellStyle2, borderpx); | |
44 | + setBorderStyle(cellStyleEx, borderpx); | |
45 | + cellStyle2.setFont(setFontStyle(workbook, "宋体", (short) 12)); | |
46 | + for (int i = 0; i < body.size(); i++) { | |
47 | + row = sheet.createRow(i + 1); | |
48 | + List<String> paramList = body.get(i); | |
49 | + for (int p = 0; p < paramList.size(); p++) { | |
50 | + cell = row.createCell(p); | |
51 | + String value = paramList.get(p); | |
52 | + if(value.contains("cellStyle")){ | |
53 | + cellStyleEx.setFillForegroundColor(IndexedColors.RED.index);//是设置前景色不是背景色 | |
54 | + cellStyleEx.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |
55 | + value = value.replace("cellStyle",""); | |
56 | + cell.setCellValue(value); | |
57 | + cell.setCellStyle(cellStyleEx); | |
58 | + }else{ | |
59 | + cell.setCellValue(value); | |
60 | + cell.setCellStyle(cellStyle2); | |
61 | + } | |
62 | + | |
63 | + } | |
64 | + } | |
65 | + for (int i = 0, isize = head.size(); i < isize; i++) { | |
66 | + sheet.autoSizeColumn(i); //设置自动列宽 | |
67 | + } | |
68 | + | |
69 | + return workbook; | |
70 | + } | |
71 | + | |
72 | + /** | |
73 | + * 以网络流的形势输出文件 | |
74 | + * @author LiuYang | |
75 | + * @param workbook 填充好的workbook | |
76 | + */ | |
77 | + public static void outFileStream(HSSFWorkbook workbook,String filename,HttpServletResponse response) { | |
78 | + try { | |
79 | + response.addHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(filename, "UTF-8")); | |
80 | + response.setContentType("application/vnd.ms-excel;charset=utf-8");//设置文本编码格式 | |
81 | + workbook.write(response.getOutputStream());//直接把内容写在响应流中 | |
82 | + } catch (FileNotFoundException e1) { | |
83 | + e1.printStackTrace(); | |
84 | + } catch (IOException e) { | |
85 | + e.printStackTrace(); | |
86 | + } | |
87 | + } | |
88 | + /** | |
89 | + * 文件输出 | |
90 | + * @author LiuYang | |
91 | + * @param workbook 填充好的workbook | |
92 | + * @param path 存放的位置 | |
93 | + */ | |
94 | + public static void outFile(HSSFWorkbook workbook,String path,HttpServletResponse response) { | |
95 | + SimpleDateFormat fDate=new SimpleDateFormat("yyyyMMdd-HH点mm分"); | |
96 | + path = path.substring(0, path.lastIndexOf(".")) + fDate.format(new Date()) + path.substring(path.lastIndexOf(".")); | |
97 | + OutputStream os=null; | |
98 | + File file = null; | |
99 | + try { | |
100 | + file = new File(path); //首先保存到自己的文件路径下面 | |
101 | + String filename = file.getName(); | |
102 | + os = new FileOutputStream(file); | |
103 | + response.addHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(filename, "UTF-8")); | |
104 | + os= new BufferedOutputStream(response.getOutputStream()); | |
105 | + response.setContentType("application/vnd.ms-excel;charset=utf-8"); | |
106 | + workbook.write(os); | |
107 | + } catch (FileNotFoundException e1) { | |
108 | + e1.printStackTrace(); | |
109 | + } catch (IOException e) { | |
110 | + e.printStackTrace(); | |
111 | + } | |
112 | + try { | |
113 | + os.flush(); | |
114 | + os.close(); | |
115 | + System.gc(); | |
116 | + System.out.println(file.delete()); | |
117 | + } catch (IOException e) { | |
118 | + e.printStackTrace(); | |
119 | + } | |
120 | + } | |
121 | + /** | |
122 | + * 设置字体样式 | |
123 | + * @author LiuYang | |
124 | + * @param workbook 工作簿 | |
125 | + * @param name 字体类型 | |
126 | + * @param height 字体大小 | |
127 | + * @return HSSFFont | |
128 | + */ | |
129 | + private static HSSFFont setFontStyle(HSSFWorkbook workbook, String name, short height) { | |
130 | + HSSFFont font = workbook.createFont(); | |
131 | + font.setFontHeightInPoints(height); | |
132 | + font.setFontName(name); | |
133 | + return font; | |
134 | + } | |
135 | + | |
136 | + /** | |
137 | + * 设置单元格样式 | |
138 | + * @author LiuYang | |
139 | + * @param cellStyle 工作簿 | |
140 | + * @param border border样式 | |
141 | + */ | |
142 | + private static void setBorderStyle(HSSFCellStyle cellStyle, BorderStyle border) { | |
143 | + | |
144 | + cellStyle.setBorderBottom(border); // 下边框 | |
145 | + cellStyle.setBorderLeft(border);// 左边框 | |
146 | + cellStyle.setBorderTop(border);// 上边框 | |
147 | + cellStyle.setBorderRight(border);// 右边框 | |
148 | + } | |
149 | +} | ... | ... |
springboot/morning-check/src/main/resources/mapper/StudentCheckReport.xml
... | ... | @@ -7,7 +7,8 @@ |
7 | 7 | <!--声明返回结果参数--> |
8 | 8 | <resultMap id="BaseResultMap" type="com.sincere.morningcheck.model.StudentCheckReport"> |
9 | 9 | <!-- id:指定查询列中的唯 一标识,即主键,可配置多个--> |
10 | - <id column="student_id" property="student_id" jdbcType="INTEGER" javaType="java.lang.Integer"/> | |
10 | + <id column="id" property="id" jdbcType="INTEGER" javaType="java.lang.Integer"/> | |
11 | + <result column="student_id" property="student_id" jdbcType="INTEGER" javaType="java.lang.Integer"/> | |
11 | 12 | <result column="cardNo" property="cardNo" jdbcType="VARCHAR" javaType="java.lang.String"/> |
12 | 13 | <result column="checkResult" property="checkResult" jdbcType="VARCHAR" javaType="java.lang.String"/> |
13 | 14 | <result column="robotResult" property="robotResult" jdbcType="VARCHAR" javaType="java.lang.String"/> |
... | ... | @@ -21,14 +22,27 @@ |
21 | 22 | </resultMap> |
22 | 23 | |
23 | 24 | <sql id="Base_Column_List"> |
24 | - student_id,cardNo,checkTime,checkResult,robotResult,intime,access,temperature,handImgId,mouthImgId,eyeImgId | |
25 | + id,student_id,cardNo,checkTime,checkResult,robotResult,intime,access,temperature,handImgId,mouthImgId,eyeImgId | |
25 | 26 | </sql> |
26 | 27 | |
27 | - <insert id="insert" parameterType="com.sincere.morningcheck.model.StudentCheckReport" > | |
28 | + <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.sincere.morningcheck.model.StudentCheckReport" > | |
28 | 29 | insert xiaoan.dbo.SZ_StudentCheckReport(student_id,cardNo,checkResult,robotResult,intime,checkTime,access,temperature,handImgId,mouthImgId,eyeImgId) |
29 | -values(#{student_id,jdbcType=VARCHAR}, #{cardNo,jdbcType=VARCHAR}, #{checkResult,jdbcType=VARCHAR}, #{robotResult,jdbcType=VARCHAR},#{inTime,jdbcType=TIMESTAMP},#{checkTime,jdbcType=TIMESTAMP},#{access,jdbcType=VARCHAR},#{temperature,jdbcType=VARCHAR},#{handImgId,jdbcType=VARCHAR},#{mouthImgId,jdbcType=VARCHAR},#{eyeImgId,jdbcType=VARCHAR}) | |
30 | +values(#{student_id,jdbcType=INTEGER}, #{cardNo,jdbcType=VARCHAR}, #{checkResult,jdbcType=VARCHAR}, #{robotResult,jdbcType=VARCHAR},#{inTime,jdbcType=TIMESTAMP},#{checkTime,jdbcType=TIMESTAMP},#{access,jdbcType=VARCHAR},#{temperature,jdbcType=VARCHAR},#{handImgId,jdbcType=VARCHAR},#{mouthImgId,jdbcType=VARCHAR},#{eyeImgId,jdbcType=VARCHAR}) | |
30 | 31 | </insert> |
31 | 32 | |
33 | + <insert id="insertCheckHis" parameterType="com.sincere.morningcheck.model.StudentCheckReportHis" > | |
34 | + insert xiaoan.dbo.SZ_StudentCheckReportHistory(check_id,student_id,cardNo,checkResult,robotResult,intime,checkTime,access,temperature,handImgId,mouthImgId,eyeImgId) | |
35 | +values(#{check_id,jdbcType=INTEGER},#{student_id,jdbcType=INTEGER}, #{cardNo,jdbcType=VARCHAR}, #{checkResult,jdbcType=VARCHAR}, #{robotResult,jdbcType=VARCHAR},#{inTime,jdbcType=TIMESTAMP},#{checkTime,jdbcType=TIMESTAMP},#{access,jdbcType=VARCHAR},#{temperature,jdbcType=VARCHAR},#{handImgId,jdbcType=VARCHAR},#{mouthImgId,jdbcType=VARCHAR},#{eyeImgId,jdbcType=VARCHAR}) | |
36 | +</insert> | |
37 | + | |
38 | + <update id="updateByStudent" parameterType="com.sincere.morningcheck.model.StudentCheckReport" > | |
39 | + update xiaoan.dbo.SZ_StudentCheckReport | |
40 | + <set>checkResult=#{checkResult,jdbcType=VARCHAR},robotResult=#{robotResult,jdbcType=VARCHAR},intime=#{inTime,jdbcType=TIMESTAMP},checkTime=#{checkTime,jdbcType=TIMESTAMP},access=#{access,jdbcType=VARCHAR},temperature=#{temperature,jdbcType=VARCHAR},handImgId=#{handImgId,jdbcType=VARCHAR},mouthImgId=#{mouthImgId,jdbcType=VARCHAR},eyeImgId=#{eyeImgId,jdbcType=VARCHAR} | |
41 | + </set> | |
42 | + where id=#{id,jdbcType=INTEGER} | |
43 | + | |
44 | + </update> | |
45 | + | |
32 | 46 | <select id="getCheckReport" resultMap="BaseResultMap"> |
33 | 47 | select <include refid="Base_Column_List"/> from xiaoan.[dbo].[SZ_StudentCheckReport] |
34 | 48 | where student_id = #{studentId} and CONVERT(varchar(10),checkTime,23) = CONVERT(varchar(10),getdate(),23) |
... | ... | @@ -45,9 +59,9 @@ values(#{student_id,jdbcType=VARCHAR}, #{cardNo,jdbcType=VARCHAR}, #{checkResult |
45 | 59 | </select> |
46 | 60 | |
47 | 61 | <select id="getCheckExReportByGrade" resultType="com.sincere.morningcheck.model.ClassExReport"> |
48 | - select a.class_id,className=a.class_name,count = count(a.class_id) from SZ_V_School_Student a join SZ_Class b on a.class_id=b.class_id | |
49 | -left join xiaoan.[dbo].[SZ_StudentCheckReport] c on a.student_id = c.student_id | |
50 | -where a.school_id=#{schoolId} and state=1 and grade=#{gradeId} and CHARINDEX('N',checkResult)>0 | |
62 | + select a.class_id,name=a.class_name,count = count(a.class_id) from SZ_V_School_Student a join SZ_Class b on a.class_id=b.class_id | |
63 | +join xiaoan.[dbo].[SZ_StudentCheckReport] c on a.student_id = c.student_id | |
64 | +where a.school_id=#{schoolId} and state=1 and grade=#{gradeId} and CHARINDEX('N',checkResult)>0 and CONVERT(varchar,checkTime,23)=#{checkTime} | |
51 | 65 | group by a.class_id,a.class_name |
52 | 66 | </select> |
53 | 67 | </mapper> |
54 | 68 | \ No newline at end of file | ... | ... |