SendUserAsync.java
2.59 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
package com.sincere.haikangface.async;
import com.sincere.haikangface.CMSServer;
import com.sincere.haikangface.dao.DeviceDao;
import com.sincere.haikangface.dao.UserDao;
import com.sincere.haikangface.utils.*;
import com.sincere.haikangface.xiananDao.SendRecordDao;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.imageio.stream.FileImageInputStream;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
@Component
public class SendUserAsync {
@Autowired
CMSServer cmsServer;
@Autowired
DeviceDao deviceDao;
@Autowired
SendRecordDao sendRecordDao;
@Autowired
UserDao userDao;
SendRecoderUtils sendRecoderUtils;
// @Async("taskExecutor")
public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, int isPiliang) {
System.out.println("下发时间设置:"+validTimeEnabled);
if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils();
//1、检测图片是否合格
boolean check = true;
if (check) {//合格
try {
CompressPic.CompressPic(srcFile, picUrl);
} catch (Exception e) {
e.printStackTrace();
}
//根据设备是5603 还是新设备
String employeeNo = "";
if (deviceId.contains("ymzx")||deviceId.contains("5607")||deviceId.contains("5671")){
employeeNo = System.currentTimeMillis()+"";
cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板");
cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划");
for (int i = 0; i < 7; i++) {
cmsServer. SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardWeekPlanTime("00:00:00", "23:00:00",""+i), "设置卡权限周计划时间");
}
cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限");
}
boolean result = cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType,employeeNo);
} else {//不合格
sendRecoderUtils.sendFail(sendRecordDao, card, srcFile, deviceId, userDao, "人脸照片不合格", userType);
}
}
}