HaikangfaceApplicationTests.java
12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
package com.sincere.haikangface;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.imaging.jpeg.JpegProcessingException;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.MetadataException;
import com.drew.metadata.exif.ExifDirectory;
import com.sincere.haikangface.admindao.ZuoyeAdminDao;
import com.sincere.haikangface.bean.*;
import com.sincere.haikangface.bean.homework.QuestionBean;
import com.sincere.haikangface.bean.xiaoan.AttendanceRecordsSS;
import com.sincere.haikangface.bean.xiaoan.CreditCardRecordsSS;
import com.sincere.haikangface.dao.DeviceDao;
import com.sincere.haikangface.dao.UserDao;
import com.sincere.haikangface.dao.ZuoYeDao;
import com.sincere.haikangface.xiananDao.SendRecordDao;
import org.bouncycastle.asn1.cms.MetaData;
import org.hibernate.validator.constraints.LuhnCheck;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class HaikangfaceApplicationTests {
@Autowired
UserDao userDao;
@Autowired
DeviceDao deviceDao;
@Autowired
SendRecordDao sendRecordDao;
@Test
public void contextLoads() {
/*
List<SendRecordBean> sendRecordBeanList = sendRecordDao.getSuccessAndFail();
System.out.println("sendRecordBeanList:" + sendRecordBeanList.size());
for (int i = 0; i < sendRecordBeanList.size(); i++) {
SendRecordBean sendRecordBean = sendRecordBeanList.get(i);
sendRecordDao.deleteFaceFail(sendRecordBean.getNum(), sendRecordBean.getDeviceID());
}
//4278190095 最小值
for (long i = 694535; i <1048577 ; i++) {
System.out.println("十六进制:FF"+splicingZero(Long.toHexString(i),5)+"F");
String CardNum = "FF"+splicingZero(Long.toHexString(i),5)+"F";
long intCardNum = Long.parseLong(CardNum,16);
System.out.println("intCardNum:"+intCardNum);
userDao.addVirtual_Card(intCardNum,0,CardNum);
// try {
// Thread.sleep(500);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}*/
}
public String splicingZero(String str, int totalLenght) {
int strLenght = str.length();
String strReturn = str;
for (int i = 0; i < totalLenght - strLenght; i++) {
strReturn = "0" + strReturn;
}
return strReturn;
}
@Test
public void send() {
/* RestTemplate restTemplate = new RestTemplate();
//失败人脸补发
List<SendRecordBean> sendRecordBeanList = sendRecordDao.getSenFail("1066",2);
int idnex = 0;
for (int i = 0; i < sendRecordBeanList.size(); i++) {
SendRecordBean sendRecordBean = sendRecordBeanList.get(i);
String url =String.format( "http://114.55.30.100:8089/facereco/sendStuCardAndImg?card=%s&deviceId=%s&endTime=%s&filePath=%s&name=%s&userType=%s&validTimeEnabled=%s&startTime=%s"
,sendRecordBean.getNum(),sendRecordBean.getDeviceID(),"2023-10-01 10:00:00",sendRecordBean.getImgPath(),sendRecordBean.getName(),"2","1","2019-10-01 10:00:00");
String result1 = restTemplate.getForObject(url, String.class);
System.out.println("下发人脸:" + result1+" idnex:"+idnex++);
// try {
// Thread.sleep(2000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}*/
/* List<HSGrade> gradeList = userDao.getGrades();
for (int i = 0; i < gradeList.size(); i++) {
HSGrade hsGrade = gradeList.get(i);
hsGrade.setUserId("zy205616");
hsGrade.setSchoolId(349);
userDao.addGrade(hsGrade.getName(), hsGrade.getAddTime(), hsGrade.getStatus(), hsGrade.getUserId(), hsGrade.getSchoolId(), hsGrade.getShortName(), hsGrade.getSchoolYear(), hsGrade.getYear(), hsGrade.getRemark(), hsGrade.getIsFinish());
}*/
/*List<HS_ResBook> hs_resBookList = userDao.getHSResBook();
for (int i = 0; i < hs_resBookList.size(); i++) {
HS_ResBook hs_resBook = hs_resBookList.get(i);
hs_resBook.setUserId("zy205616");
hs_resBook.setSchoolId("349");
userDao.addHSResBook(hs_resBook.getName(), hs_resBook.getAddTime(), hs_resBook.getStatus(), hs_resBook.getUserId(), hs_resBook.getSchoolId(), hs_resBook.getPress(), hs_resBook.getPressTimes(), hs_resBook.getPrice());
}*/
/*List<SubjectBean> subjectBeans = userDao.getSubjects();
for (int i = 0; i < subjectBeans.size(); i++) {
SubjectBean subjectBean = subjectBeans.get(i);
subjectBean.setSchool_id(349);
userDao.addSubjectbean(subjectBean.getSchool_id(),subjectBean.getSubject_name(),subjectBean.getIntime(),subjectBean.getSubId(),
subjectBean.getIsElective(),subjectBean.getStatus(),subjectBean.getTypeId(),subjectBean.getMaxPerson(),subjectBean.getShortName());
}*/
/* List<HS_ResBookVersion> hs_resBookVersions = userDao.getResBookVersion();
for (int i = 0; i < hs_resBookVersions.size(); i++) {
HS_ResBookVersion hs_resBookVersion = hs_resBookVersions.get(i);
hs_resBookVersion.setSchoolId(349);
String gradeName = userDao.getGradeName(hs_resBookVersion.getGradeId() + "");
hs_resBookVersion.setGradeId(Integer.parseInt(userDao.getGradeId(gradeName)));
String subjectName = userDao.getSubjectName(hs_resBookVersion.getSubjectId());
hs_resBookVersion.setSubjectId(Integer.parseInt(userDao.getSubjectId(subjectName)));
String bookName = userDao.getBookName(hs_resBookVersion.getBookId());
hs_resBookVersion.setBookId(userDao.getBookId(bookName));
userDao.addResBookVersion(hs_resBookVersion.getBookId(), hs_resBookVersion.getGradeId(), hs_resBookVersion.getSubjectId(), hs_resBookVersion.getIsUse(), hs_resBookVersion.getState(), hs_resBookVersion.getIntime(), hs_resBookVersion.getSchoolId());
}*/
/* List<HS_ResChapter> hs_resChapters = userDao.getChapters();
List<String> ver1 = userDao.getbookversionId("349");
List<String> ver2 = userDao.getbookversionId("350");
System.out.println(ver1.toString()+ " ------- "+ver2.toString());
for (int i = 0; i < hs_resChapters.size(); i++) {
HS_ResChapter hs_resChapter = hs_resChapters.get(i);
int position = index(hs_resChapter.getBookVersionId()+"",ver2);
System.out.println("position:"+position+" name:"+hs_resChapter.getName()+" bookid:"+hs_resChapter.getBookVersionId());
if (position!=-1){
String bookversionId = ver1.get(position);
hs_resChapter.setBookVersionId(Integer.parseInt(bookversionId));
hs_resChapter.setUserId("zy205616");
hs_resChapter.setSchoolId(349);
userDao.addChapter(hs_resChapter.getName(),hs_resChapter.getSubjectId(),hs_resChapter.getGradeId(),hs_resChapter.getPid(),
hs_resChapter.getJiaoCaiId(),hs_resChapter.getBookVersionId(),hs_resChapter.getSort(),hs_resChapter.getType(),
hs_resChapter.getAddTime(),hs_resChapter.getStatus(),hs_resChapter.getUserId(),hs_resChapter.getSchoolId());
}
}*/
/*List<HS_ResChapter> hs_resChapters = userDao.getChapters();
for (int i = 0; i < hs_resChapters.size(); i++) {
HS_ResChapter hs_resChapter = hs_resChapters.get(i);
if (hs_resChapter.getPid()!=0){
System.out.println("hs_resChapter:"+hs_resChapter.getName());
String chaname = userDao.getChapterName(hs_resChapter.getPid());
String chapterId = userDao.getChapterId(chaname);//349的章节主目录
hs_resChapter.setUserId("zy205616");
hs_resChapter.setSchoolId(349);
userDao.updateChapter(hs_resChapter.getUserId(),hs_resChapter.getName(),chapterId);
}
}*/
}
private int index(String content, List<String> list) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).trim().equals(content.trim())) return i;
}
return -1;
}
@Test
public void getDevice() {
/*File file = new File("C:\\TaoHandong\\copy\\1\\21_指纹签到.txt");
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
String content = null;
Set<String> strings = new HashSet<>();//存放studentid
while ((content = bufferedReader.readLine()) != null) {
if (content.contains("0x26")) {
strings.add(content.split("cardNo:")[1]);
}
}
System.out.println("指纹签到数据:" + strings.size());
File fileKQ = new File("C:\\TaoHandong\\copy\\考勤人员.txt");
BufferedReader bufferedReader1 = new BufferedReader(new FileReader(fileKQ));
Set<String> stringsKQ = new HashSet<>();//存放studentid
String contentKQ=null;
while ((contentKQ = bufferedReader1.readLine()) != null) {
stringsKQ.add(contentKQ);
}
System.out.println("考勤人员:" +stringsKQ.size());
Set<String> stringsKQ_Fail = new HashSet<>();
Iterator iteratorstr = strings.iterator();
while (iteratorstr.hasNext()){
String stKQ = (String) iteratorstr.next();
boolean isHas = false;
Iterator iteratorKQ = stringsKQ.iterator();
while (iteratorKQ.hasNext()){
String KQ = (String) iteratorKQ.next();
if (stKQ.equals(KQ))isHas = true;
}
if (!isHas)stringsKQ_Fail.add("'"+stKQ+"'");
}
System.out.println("考勤失败人员数据:" +stringsKQ_Fail.size()+ stringsKQ_Fail.toString());
File fileQD = new File("C:\\TaoHandong\\copy\\签到人员.txt");
BufferedReader bufferedReaderQD = new BufferedReader(new FileReader(fileQD));
String contentQD = null;
Set<String> stringsQD = new HashSet<>();//存放studentid
while ((contentQD = bufferedReaderQD.readLine()) != null) {
stringsQD.add(contentQD);
}
System.out.println("4200签到记录:" + stringsQD.size());
Iterator iteratorQD = stringsQD.iterator();
Set<String> resultHas = new HashSet<>();
while (iteratorQD.hasNext()){
String studentId1 = (String) iteratorQD.next();
Iterator iterator = strings.iterator();
boolean isHas = false;
while (iterator.hasNext()){
String studentId2 = (String) iterator.next();
if (studentId1.equals(studentId2))isHas=true;
}
if (!isHas){
resultHas.add("'"+studentId1+"'");
}
}
System.out.println("没上传的人员:" + resultHas.toString());
}catch (Exception e){
e.printStackTrace();
}*/
}
@Autowired
ZuoYeDao zuoYeDao;
@Autowired
ZuoyeAdminDao zuoyeAdminDao;
@Test
public void fileRes() {
List<QuestionBean> questionBeans = zuoYeDao.getQuestionsRecent();
/* List<QuestionBean> questionBeans = zuoYeDao.getQuestionsRecent();
String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
for (QuestionBean ques :
questionBeans) {
zuoyeAdminDao.addQuestionStem("请回答下列问题", "1", dateTime);
int stemId = zuoyeAdminDao.getStemId();
String intime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
zuoyeAdminDao.addQuestion(ques.getQuestion(),ques.getQtype(),ques.getAnswer(),ques.getCorrectAnswer(),ques.getAnalysis(),
ques.getState(),intime,stemId+"",ques.getExamineFlag(),ques.getSubjectId(),"10","1",ques.getChapterId(),ques.getGradeId()+"","1","","1");
}*/
List<Long> queIds = zuoyeAdminDao.getQueIds();
for (int i = queIds.size()-1; i >=0 ; i--) {
zuoyeAdminDao.addYYQuestionAndKnowledg(queIds.get(i), Long.parseLong(questionBeans.get(questionBeans.size()-1-i).getKnowledgeId()),0,1);
}
}
}