SearchMapperTest.java
8.78 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
package com.example.dahua.mapper;
import com.alibaba.fastjson.JSON;
import com.example.dahua.MyTask;
import com.example.dahua.Tester;
import com.example.dahua.async.MyScheduledTask;
import com.example.dahua.async.SendFaceBatchTask2;
import com.example.dahua.bean.*;
import com.example.dahua.dao.PermissionFaceDao;
import com.example.dahua.dao.UserDao;
import com.example.dahua.enums.EnumSzBusinessType;
import com.example.dahua.mqtt.MqttManager;
import com.example.dahua.service.DeleteBatchTest;
import com.example.dahua.service.PermissFaceService;
import com.example.dahua.service.UserService;
import com.example.dahua.utils.BaiduUtils;
import com.example.dahua.utils.DateUtils;
import com.example.dahua.utils.HttpUtil;
import com.example.dahua.utils.JsonUtils;
import com.example.dahua.xiananDao.SearchMapper;
import com.example.dahua.xiananDao.SendRecordDao;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;
/**
* TODO
*
* @author xuquan
* @date 2020/11/11 12:13
*/
public class SearchMapperTest extends Tester {
@Autowired
private SearchMapper searchMapper;
@Autowired
private UserDao userDao;
@Autowired
private UserService userService;
@Autowired
private PermissionFaceDao permissionFaceDao;
@Autowired
private PermissFaceService permissFaceService;
@Autowired
private DeleteBatchTest deleteBatchTest;
@Test
public void test(){
AttendanceBean attendanceBean =userDao.getTypeByClint_id("ytj01hzszdddddddd");
String outOrIn = attendanceBean.getOutOrIn();
//有效刷卡调考勤存储过程
CheckIn checkIn = new CheckIn();
checkIn.setDeviceId("ytj01hzszdddddddd");
checkIn.setCardNo("611621AC");
checkIn.setFunNo(8);
checkIn.setFlag(Integer.parseInt(outOrIn) == EnumSzBusinessType.EnumDeviceInAndOut.INT.code ? 0:1);
checkIn.setCheckTime("2020-11-20 12:19:12");
searchMapper.checkIn(checkIn);
System.out.println(JSON.toJSON(checkIn));
}
@Test
public void test2(){
userDao.checkLeave("234232");
System.out.println(JSON.toJSON(userDao.checkLeave("234232")));
userDao.selectByParentMobile("234232");
System.out.println(JSON.toJSON(userDao.selectByParentMobile("234232")));
// userDao.checkLeave("234232");
// System.out.println(JSON.toJSON(userDao.checkLeave("234232")));
}
@Test
public void test3(){
ShortMsg shortMsg = new ShortMsg();
String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
shortMsg.setTableName("smsNew" + tableSuffix);
shortMsg.setSchoolId(23);
shortMsg.setMobile("124124242");
// userDao.insertMessage();
// System.out.println(JSON.toJSON(userDao.checkLeave("234232")));
}
@Test
public void test4(){
PermissionFaceBean faceBean = permissionFaceDao.getPerFaceWithId(45);
System.out.println(JsonUtils.nonDefaultMapper().toJson(faceBean));
faceBean.setType(1);
String json = "{\"studentType\":\"1\",\"deviceIds\":[\"ytj01hzszdddddddd\"],\"weekDays\":[{\"weekTimes\":[{\"startTime\":\"10:00\",\"endTime\":\"12:05\"}],\"sex\":\"1\",\"weekDay\":\"3,4,5\"}]}";
PermissionBean permissionBean = JsonUtils.nonDefaultMapper().fromJson(json,PermissionBean.class);
faceBean.setPermissionBean(permissionBean);
faceBean.setPerrmissName("顺治测试学校");
faceBean.setChannel("");
faceBean.setCustomName("");
permissFaceService.addPermissionFace(faceBean);
}
private MqttManager mqttManager;
// @Autowired
// private MyTask myTask;
// @Test
// public void test5(){
// if(null == mqttManager){
// mqttManager = new MqttManager();
// mqttManager.init();
// }
//
// String eventTime = DateUtils.date2String(new Date(), DateUtils.format2);
// String deviceId ="";
// String cardNo ="";
// String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:进门" + "______" + eventTime;
//
// myTask.sendMQMess(deviceId,cardNo,1);
// System.out.println("发送成功");
// }
@Test
public void test6() {
// String path = "D://dahua-logs/sxzx2020889.png";
String path = "D://dahua-logs/sxzx2020002.png";
userService.test(path);
}
@Test
public void test7() {
String schoolId = "1037";
deleteBatchTest.test(schoolId);
}
@Test
public void test8() {
// String schoolId = "1037";
// deleteBatchTest.test2(schoolId);
String schoolId = "1485";
deleteBatchTest.test3(schoolId);
}
@Test
public void test9() {
String cardNum="8733277A";
String intime= "2021-01-28 20:47:14";
String systime="2021-01-28 20:47:23";
String clientId ="253169469";
deleteBatchTest.test5(cardNum,intime,systime,clientId);
}
@Test
public void test10() {
//男
Integer roomId =11748;
// String roomId ="12226";
Integer type = 12;
Integer outof = 0;
String intime = "2021-01-24 20:26:14";
String clintId="253169240";
String startTime= "2021-01-24 00:00:00";
String endTime ="2021-01-24 23:59:59";
deleteBatchTest.test6(27,roomId,type,outof,intime,clintId,startTime,endTime);
}
@Test
public void test11() {
//男11748
Integer roomId =11748;
// String roomId ="12226";
Integer type = 7;
Integer outof = 1;
String intime = "2021-01-08 06:03:39";
String clintId="253169240";
String startTime= "2021-01-08 00:00:00";
String endTime ="2021-01-08 23:59:59";
deleteBatchTest.test6(27,roomId,type,outof,intime,clintId,startTime,endTime);
}
@Test
public void test12() {
//男
Integer roomId =11748;
// String roomId ="12226";
// Integer type = 7;
// Integer outof = 1;
Integer type = 12;
Integer outof = 0;
String startTime= "2021-01-24 00:00:00";
String endTime ="2021-01-09 23:59:59";
deleteBatchTest.test8(27,roomId,type,outof,startTime,endTime,47);
}
@Test
public void test13() {
//男11748
Integer roomId =12226;
// String roomId ="12226";
Integer type =1;
Integer outof = 0;
String intime = "2021-01-21 06:03:39";
String clintId="253185199";
String startTime= "2021-01-21 00:00:00";
String endTime ="2021-01-21 23:59:59";
deleteBatchTest.test7(27,roomId,type,outof,intime,clintId,startTime,endTime);
}
@Test
public void test14() {
//男11748
Integer roomId =12226;
// String roomId ="12226";
Integer type =4;
Integer outof = 1;
String intime = "2021-01-20 17:14:39";
String clintId="253185199";
String startTime= "2021-01-20 00:00:00";
String endTime ="2021-01-20 23:59:59";
deleteBatchTest.test7(27,roomId,type,outof,intime,clintId,startTime,endTime);
}
@Autowired
private SendRecordDao sendRecordDao;
@Test
public void test15() {
//男
Integer schoolId=27;
Integer roomId =12226;
Integer type = 4;
Integer outof = 0;
String clintId="253169212";
String timeIds = "2021-01-08,2021-01-11,2021-01-12,2021-01-13,2021-01-14,2021-01-15,2021-01-18,2021-01-19,2021-01-20,2021-01-21,2021-01-22";
String[] deviceArr = timeIds.split(",");
List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr));
//启用多线程执行
CountDownLatch begin = new CountDownLatch(1);
CountDownLatch end = new CountDownLatch(deviceList.size());
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-sendFace-runner-%d").build();
ExecutorService exe = new ThreadPoolExecutor(8,16,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(),namedThreadFactory);
for(String s : deviceList){
String intime = s + " 06:03:39";
String startTime= s + " 00:00:00";
String endTime = s+" 23:59:59";
exe.execute(new SendFaceBatchTask2(userDao,sendRecordDao,searchMapper,schoolId,roomId,type,outof,intime,clintId,startTime,endTime,begin,end));
}
begin.countDown();
try {
end.await();
}catch (Exception e){
e.printStackTrace();
}
exe.shutdown();
System.out.println("统计100服务器总共有"+deviceList.size()+"个设备,处理完毕");
}
}