Commit 2f519872b8bd71d0aad466649cbc4003743bb2d9

Authored by 徐泉
1 parent 38841d26
Exists in master

修改提交

Showing 19 changed files with 603 additions and 1830 deletions   Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
... ... @@ -672,8 +672,8 @@ public class MyTask implements ApplicationRunner {
672 672 //考勤成功
673 673 String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:" + (eventType == 1 ? "进门" : "出门") + "______" + eventTime;
674 674  
675   - //开始推送看板
676   - sendMQMess(deviceId,cardNo,eventType);
  675 +// //开始推送看板
  676 +// sendMQMess(deviceId,cardNo,eventType);
677 677  
678 678 //记录学生考勤签到记录
679 679 FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoSuccess);
... ...
cloud/dahua/src/main/java/com/example/dahua/mqtt/MqttManager.java
... ... @@ -21,75 +21,75 @@ public class MqttManager {
21 21 private static int qosLevel;
22 22  
23 23 public void init() {
24   - final String brokerUrl = "tcp://post-cn-4590mq2hr03.mqtt.aliyuncs.com:1883";
25   - groupId = "GID_HFJSIURFHAQO110";
26   - topic = "Topic_Quene_Test";
27   - qosLevel = 1;
28   - final Boolean cleanSession = false;
29   - String clientId = groupId + "@@@9ED96FB6D72C1698";
30   - accessKey = "UimvLVp0Wj90P88u";
31   - String secretKey = "TE4rZenITG27tiQqHx9qINjx71Nws7";
32   - final MemoryPersistence memoryPersistence = new MemoryPersistence();
33   - if (null == mqttClient) {
34   - try {
35   - mqttClient = new MqttClient(brokerUrl, clientId, memoryPersistence);
36   - } catch (MqttException e) {
37   - e.printStackTrace();
38   - }
39   - MqttConnectOptions connOpts = new MqttConnectOptions();
40   - //cal the sign as password,sign=BASE64(MAC.SHA1(groupId,secretKey))
41   - try {
42   - sign = Tools.macSignature(clientId.split("@@@")[0], secretKey);
43   - } catch (InvalidKeyException e) {
44   - e.printStackTrace();
45   - } catch (NoSuchAlgorithmException e) {
46   - e.printStackTrace();
47   - }
48   - connOpts.setUserName(accessKey);
49   - connOpts.setPassword(sign.toCharArray());
50   - connOpts.setCleanSession(cleanSession);
51   - connOpts.setKeepAliveInterval(90);
52   - connOpts.setAutomaticReconnect(true);
53   - mqttClient.setCallback(new MqttCallbackExtended() {
54   - @Override
55   - public void connectComplete(boolean reconnect, String serverURI) {
56   - System.out.println("connect success");
57   - }
58   -
59   - @Override
60   - public void connectionLost(Throwable throwable) {
61   - System.out.println("connect lost:" + throwable.toString());
62   - throwable.printStackTrace();
63   - init();//初始化
64   - }
65   -
66   - @Override
67   - public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
68   - System.out.println("receive msg from topic " + s + " , body is " + new String(mqttMessage.getPayload()));
69   - }
70   -
71   - @Override
72   - public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
73   - //this notice make sense when qos >0
74   -// System.out.println("send msg succeed");
75   - }
76   - });
77   - try {
78   - mqttClient.connect(connOpts);
79   - } catch (MqttException e) {
80   - System.out.println("mqtt:" + e.toString());
81   - e.printStackTrace();
82   - }
83   - /*while (true){
84   - sendMessageTest("528C8E6CD4A3C659","zy105387",0);
85   - try {
86   - Thread.sleep(10000);
87   - } catch (InterruptedException e) {
88   - System.out.println("connect success:"+e);
89   - e.printStackTrace();
90   - }
91   - }*/
92   - }
  24 +// final String brokerUrl = "tcp://post-cn-4590mq2hr03.mqtt.aliyuncs.com:1883";
  25 +// groupId = "GID_HFJSIURFHAQO110";
  26 +// topic = "Topic_Quene_Test";
  27 +// qosLevel = 1;
  28 +// final Boolean cleanSession = false;
  29 +// String clientId = groupId + "@@@9ED96FB6D72C1698";
  30 +// accessKey = "UimvLVp0Wj90P88u";
  31 +// String secretKey = "TE4rZenITG27tiQqHx9qINjx71Nws7";
  32 +// final MemoryPersistence memoryPersistence = new MemoryPersistence();
  33 +// if (null == mqttClient) {
  34 +// try {
  35 +// mqttClient = new MqttClient(brokerUrl, clientId, memoryPersistence);
  36 +// } catch (MqttException e) {
  37 +// e.printStackTrace();
  38 +// }
  39 +// MqttConnectOptions connOpts = new MqttConnectOptions();
  40 +// //cal the sign as password,sign=BASE64(MAC.SHA1(groupId,secretKey))
  41 +// try {
  42 +// sign = Tools.macSignature(clientId.split("@@@")[0], secretKey);
  43 +// } catch (InvalidKeyException e) {
  44 +// e.printStackTrace();
  45 +// } catch (NoSuchAlgorithmException e) {
  46 +// e.printStackTrace();
  47 +// }
  48 +// connOpts.setUserName(accessKey);
  49 +// connOpts.setPassword(sign.toCharArray());
  50 +// connOpts.setCleanSession(cleanSession);
  51 +// connOpts.setKeepAliveInterval(90);
  52 +// connOpts.setAutomaticReconnect(true);
  53 +// mqttClient.setCallback(new MqttCallbackExtended() {
  54 +// @Override
  55 +// public void connectComplete(boolean reconnect, String serverURI) {
  56 +// System.out.println("connect success");
  57 +// }
  58 +//
  59 +// @Override
  60 +// public void connectionLost(Throwable throwable) {
  61 +// System.out.println("connect lost:" + throwable.toString());
  62 +// throwable.printStackTrace();
  63 +// init();//初始化
  64 +// }
  65 +//
  66 +// @Override
  67 +// public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
  68 +// System.out.println("receive msg from topic " + s + " , body is " + new String(mqttMessage.getPayload()));
  69 +// }
  70 +//
  71 +// @Override
  72 +// public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
  73 +// //this notice make sense when qos >0
  74 +//// System.out.println("send msg succeed");
  75 +// }
  76 +// });
  77 +// try {
  78 +// mqttClient.connect(connOpts);
  79 +// } catch (MqttException e) {
  80 +// System.out.println("mqtt:" + e.toString());
  81 +// e.printStackTrace();
  82 +// }
  83 +// /*while (true){
  84 +// sendMessageTest("528C8E6CD4A3C659","zy105387",0);
  85 +// try {
  86 +// Thread.sleep(10000);
  87 +// } catch (InterruptedException e) {
  88 +// System.out.println("connect success:"+e);
  89 +// e.printStackTrace();
  90 +// }
  91 +// }*/
  92 +// }
93 93 }
94 94  
95 95 public void sendMq(String deviceId, String cmd) {
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
... ... @@ -245,13 +245,6 @@ public class CMSServer implements ApplicationRunner {
245 245 }
246 246 pInBuffer.dwSize = pInBuffer.size();
247 247 saveAttendance(deviceId);
248   - /*这里加判断即可,可以通过byDeviceID、sDeviceSerial、sDevName 进行判断
249   - if(strDevRegInfo.dwDevType == 1) {
250   - pInBuffer.dwAlarmServerType = 3;
251   - } else{
252   - pInBuffer.dwAlarmServerType = 1;
253   - }
254   - */
255 248 byte[] byIP = ip_cloud.getBytes();
256 249 System.arraycopy(byIP, 0, pInBuffer.struUDPAlarmSever.szIP, 0, byIP.length);
257 250 // TODO: 2020/8/27 人脸机类型为0
... ... @@ -1052,7 +1045,7 @@ public class CMSServer implements ApplicationRunner {
1052 1045 deviceDao.updateDeviceStatu(1,inTime,deviceId);
1053 1046 } else {
1054 1047 deviceDao.addDevide(attendanceBean.getClint_id(), attendanceBean.getClint_type(), attendanceBean.getIntime(),
1055   - attendanceBean.getSchool_id(), attendanceBean.getState() + "", attendanceBean.getIsConnection() + "");
  1048 + attendanceBean.getSchool_id(),attendanceBean.getState() + "", attendanceBean.getIsConnection() + "");
1056 1049 }
1057 1050 }
1058 1051 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
... ... @@ -55,7 +55,8 @@ public class SendUserAsync {
55 55 * @param deviceId
56 56 * @param userType
57 57 */
58   - public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType,Integer schoolId,String cardNum) {
  58 + public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime,
  59 + int validTimeEnabled, String name, String deviceId, String userType,Integer schoolId,String cardNum) {
59 60 //1、检测图片是否合格
60 61 boolean check = true;
61 62 if (check) {//合格
... ... @@ -70,25 +71,6 @@ public class SendUserAsync {
70 71 String resultCard = getCard(String.format("%08x", lon)).toUpperCase();
71 72 //系统时间
72 73 String time = System.currentTimeMillis() + "";
73   - //1老师;2学生
74   - if (Integer.parseInt(userType) ==EnumSzBusinessType.EnumUserType.TEACHER.code) {
75   - //根据卡号获取老师信息
76   - StudentBean studentBean = userDao.getTeacherWithCard(resultCard,schoolId);
77   - if (null == studentBean) {
78   - employeeNo = time.substring(time.length() - 6, time.length());
79   - } else{
80   - employeeNo = studentBean.getTeacher_id();
81   - }
82   - }
83   - if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.STUDENT.code) {
84   - //根据卡号获取学生信息
85   - StudentBean studentBean = userDao.getStudentWithCard(resultCard,schoolId);
86   - if (null == studentBean) {
87   - employeeNo = time.substring(time.length() - 6, time.length());
88   - } else{
89   - employeeNo = studentBean.getStudent_id();
90   - }
91   - }
92 74 //设置卡权限计划模板
93 75 cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板",schoolId,cardNum);
94 76 //设置卡权限周计划
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/SendRecordBean.java
1 1 package com.sincere.haikangface.bean;
2 2  
  3 +import lombok.Data;
  4 +
3 5 import java.io.Serializable;
4 6  
5 7 /**
6 8 * 人脸下发记录
7 9 */
  10 +@Data
8 11 public class SendRecordBean implements Serializable {
9 12  
10   -
11 13 private String customerid;//用户编号
12 14  
13 15 private String Num;
14 16  
15 17 private String Name;
16 18  
17   - private int schoolId;
  19 + private Integer schoolId;
  20 +
  21 + private String userId;
18 22  
19 23 private String schoolName;//下发结果
20 24  
... ... @@ -22,117 +26,13 @@ public class SendRecordBean implements Serializable {
22 26  
23 27 private String imgPath;//下发的图片路径
24 28  
25   - private int userType;
  29 + private Integer userType;
26 30  
27 31 private String time;
28 32  
29 33 private String failContent;
30 34  
31 35 private int failType;
32   -
33   -
34   - public String getCustomerid() {
35   - return customerid;
36   - }
37   -
38   - public void setCustomerid(String customerid) {
39   - this.customerid = customerid;
40   - }
41   -
42   - public String getNum() {
43   - return Num;
44   - }
45   -
46   - public void setNum(String num) {
47   - Num = num;
48   - }
49   -
50   - public String getName() {
51   - return Name;
52   - }
53   -
54   - public void setName(String name) {
55   - Name = name;
56   - }
57   -
58   - public int getSchoolId() {
59   - return schoolId;
60   - }
61   -
62   - public void setSchoolId(int schoolId) {
63   - this.schoolId = schoolId;
64   - }
65   -
66   - public String getSchoolName() {
67   - return schoolName;
68   - }
69   -
70   - public void setSchoolName(String schoolName) {
71   - this.schoolName = schoolName;
72   - }
73   -
74   - public String getDeviceID() {
75   - return deviceID;
76   - }
77   -
78   - public void setDeviceID(String deviceID) {
79   - this.deviceID = deviceID;
80   - }
81   -
82   - public String getImgPath() {
83   - return imgPath;
84   - }
85   -
86   - public void setImgPath(String imgPath) {
87   - this.imgPath = imgPath;
88   - }
89   -
90   - public int getUserType() {
91   - return userType;
92   - }
93   -
94   - public void setUserType(int userType) {
95   - this.userType = userType;
96   - }
97   -
98   - public String getTime() {
99   - return time;
100   - }
101   -
102   - public void setTime(String time) {
103   - this.time = time;
104   - }
105   -
106   - public String getFailContent() {
107   - return failContent;
108   - }
109   -
110   - public void setFailContent(String failContent) {
111   - this.failContent = failContent;
112   - }
113   -
114   - public int getFailType() {
115   - return failType;
116   - }
117   -
118   - public void setFailType(int failType) {
119   - this.failType = failType;
120   - }
121   -
122   - @Override
123   - public String toString() {
124   - return "SendRecordBean{" +
125   - "customerid='" + customerid + '\'' +
126   - ", Num='" + Num + '\'' +
127   - ", Name='" + Name + '\'' +
128   - ", schoolId=" + schoolId +
129   - ", schoolName='" + schoolName + '\'' +
130   - ", deviceID='" + deviceID + '\'' +
131   - ", imgPath='" + imgPath + '\'' +
132   - ", userType=" + userType +
133   - ", time='" + time + '\'' +
134   - ", failContent='" + failContent + '\'' +
135   - ", failType=" + failType +
136   - '}';
137   - }
138   -}
  36 + //1成功2失败
  37 + private Integer status;
  38 +}
139 39 \ No newline at end of file
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/AuthRecordDto.java
... ... @@ -2,6 +2,7 @@ package com.sincere.haikangface.bean.face;
2 2  
3 3 import io.swagger.annotations.ApiModel;
4 4 import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
5 6  
6 7 import java.util.List;
7 8  
... ... @@ -10,6 +11,7 @@ import java.util.List;
10 11 * @author xuquan
11 12 * @date 2020/12/16 09:10
12 13 */
  14 +@Data
13 15 @ApiModel
14 16 public class AuthRecordDto {
15 17  
... ... @@ -27,60 +29,4 @@ public class AuthRecordDto {
27 29 private List<WeekDay> weekDays ;
28 30 @ApiModelProperty("权限类型1微耕权限2人脸机权限")
29 31 private Integer authType;
30   -
31   - public Integer getId() {
32   - return id;
33   - }
34   -
35   - public void setId(Integer id) {
36   - this.id = id;
37   - }
38   -
39   - public Integer getType() {
40   - return type;
41   - }
42   -
43   - public void setType(Integer type) {
44   - this.type = type;
45   - }
46   -
47   - public Integer getSchoolId() {
48   - return schoolId;
49   - }
50   -
51   - public void setSchoolId(Integer schoolId) {
52   - this.schoolId = schoolId;
53   - }
54   -
55   - public List<String> getSnList() {
56   - return snList;
57   - }
58   -
59   - public void setSnList(List<String> snList) {
60   - this.snList = snList;
61   - }
62   -
63   - public Integer getStudentType() {
64   - return studentType;
65   - }
66   -
67   - public void setStudentType(Integer studentType) {
68   - this.studentType = studentType;
69   - }
70   -
71   - public List<WeekDay> getWeekDays() {
72   - return weekDays;
73   - }
74   -
75   - public void setWeekDays(List<WeekDay> weekDays) {
76   - this.weekDays = weekDays;
77   - }
78   -
79   - public Integer getAuthType() {
80   - return authType;
81   - }
82   -
83   - public void setAuthType(Integer authType) {
84   - this.authType = authType;
85   - }
86 32 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionBean.java
1 1 package com.sincere.haikangface.bean.face;
2 2  
3 3 import io.swagger.annotations.ApiModelProperty;
  4 +import lombok.Data;
4 5  
5 6 import java.io.Serializable;
6 7 import java.util.List;
7 8  
  9 +@Data
8 10 public class PermissionBean implements Serializable {
9 11  
10 12 @ApiModelProperty("设备ID,批量用英文逗号,隔开")
... ... @@ -21,44 +23,4 @@ public class PermissionBean implements Serializable {
21 23  
22 24 @ApiModelProperty("用户ID,批量用英文逗号,隔开")
23 25 private String userIds;
24   -
25   - public String getUserIds() {
26   - return userIds;
27   - }
28   -
29   - public void setUserIds(String userIds) {
30   - this.userIds = userIds;
31   - }
32   -
33   - public List<String> getDeviceIds() {
34   - return deviceIds;
35   - }
36   -
37   - public void setDeviceIds(List<String> deviceIds) {
38   - this.deviceIds = deviceIds;
39   - }
40   -
41   - public String getSchoolId() {
42   - return schoolId;
43   - }
44   -
45   - public void setSchoolId(String schoolId) {
46   - this.schoolId = schoolId;
47   - }
48   -
49   - public String getUserType() {
50   - return userType;
51   - }
52   -
53   - public void setUserType(String userType) {
54   - this.userType = userType;
55   - }
56   -
57   - public List<WeekDay> getWeekDays() {
58   - return weekDays;
59   - }
60   -
61   - public void setWeekDays(List<WeekDay> weekDays) {
62   - this.weekDays = weekDays;
63   - }
64 26 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/SendFaceBean.java
1 1 package com.sincere.haikangface.bean.face;
2 2  
3   -public class SendFaceBean {
4   -
5   - private String card;
6   -
7   - private String name;
8   -
9   - private String deviceId;
10   -
11   - private String startTime;
  3 +import com.fasterxml.jackson.annotation.JsonIgnore;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +import org.apache.commons.lang3.StringUtils;
12 7  
13   - private String endTime;
  8 +import javax.validation.constraints.NotNull;
  9 +import java.util.Arrays;
  10 +import java.util.List;
14 11  
15   - private int validTimeEnabled;
16   -
17   - private String userType;
  12 +@Data
  13 +public class SendFaceBean {
18 14  
19   - public String getCard() {
20   - return card;
21   - }
  15 + @NotNull(message = "学校ID必传")
  16 + @ApiModelProperty("学校ID")
  17 + private Integer schoolId;
22 18  
23   - public void setCard(String card) {
24   - this.card = card;
25   - }
  19 + @ApiModelProperty("学生类型1老师2学生")
  20 + private Integer userType;
26 21  
27   - public String getName() {
28   - return name;
29   - }
  22 + @ApiModelProperty("学生类型1通校2住校3通晚4其他")
  23 + private Integer studentType;
30 24  
31   - public void setName(String name) {
32   - this.name = name;
33   - }
  25 + @ApiModelProperty("性别,多个英文逗号隔开")
  26 + private String sex;
34 27  
35   - public String getDeviceId() {
36   - return deviceId;
37   - }
  28 + @ApiModelProperty("下发人脸照")
  29 + private String photo;
38 30  
39   - public void setDeviceId(String deviceId) {
40   - this.deviceId = deviceId;
41   - }
  31 + @ApiModelProperty("下发班级,多个英文逗号隔开")
  32 + private String classIds;
42 33  
43   - public String getStartTime() {
44   - return startTime;
45   - }
  34 + @ApiModelProperty("下发设备,多个英文逗号隔开")
  35 + private String deviceIds;
46 36  
47   - public void setStartTime(String startTime) {
48   - this.startTime = startTime;
49   - }
  37 + @ApiModelProperty("下发卡号,多个英文逗号隔开")
  38 + private String cardNos;
50 39  
51   - public String getEndTime() {
52   - return endTime;
53   - }
  40 + @ApiModelProperty("是否检验人脸1是2否,默认2")
  41 + private Integer isCheck = 2;
54 42  
55   - public void setEndTime(String endTime) {
56   - this.endTime = endTime;
57   - }
  43 + @ApiModelProperty("宿舍分组ID")
  44 + private Integer roomId;
58 45  
59   - public int getValidTimeEnabled() {
60   - return validTimeEnabled;
61   - }
  46 + @ApiModelProperty("下发状态")
  47 + private Integer status;
62 48  
63   - public void setValidTimeEnabled(int validTimeEnabled) {
64   - this.validTimeEnabled = validTimeEnabled;
  49 + @JsonIgnore
  50 + public List<String> getSexList(){
  51 + if(StringUtils.isNotBlank(getSex())) return Arrays.asList(getSex().split(","));
  52 + return null;
65 53 }
66 54  
67   - public String getUserType() {
68   - return userType;
  55 + @JsonIgnore
  56 + public List<String> getClassList(){
  57 + if(StringUtils.isNotBlank(getClassIds())) return Arrays.asList(getClassIds().split(","));
  58 + return null;
69 59 }
70 60  
71   - public void setUserType(String userType) {
72   - this.userType = userType;
  61 + @JsonIgnore
  62 + public List<String> getDeviceList(){
  63 + if(StringUtils.isNotBlank(getDeviceIds())) return Arrays.asList(getDeviceIds().split(","));
  64 + return null;
73 65 }
74 66  
75   - @Override
76   - public String toString() {
77   - return "SendFaceBean{" +
78   - "card='" + card + '\'' +
79   - ", name='" + name + '\'' +
80   - ", deviceId='" + deviceId + '\'' +
81   - ", startTime='" + startTime + '\'' +
82   - ", endTime='" + endTime + '\'' +
83   - ", validTimeEnabled=" + validTimeEnabled +
84   - ", userType='" + userType + '\'' +
85   - '}';
  67 + @JsonIgnore
  68 + public List<String> getCardList(){
  69 + if(StringUtils.isNotBlank(getCardNos())) return Arrays.asList(getCardNos().split(","));
  70 + return null;
86 71 }
87 72 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java
... ... @@ -4,14 +4,14 @@ import com.sincere.haikangface.bean.Result;
4 4 import com.sincere.haikangface.bean.ResultGenerator;
5 5 import com.sincere.haikangface.bean.face.AuthRecordDto;
6 6 import com.sincere.haikangface.bean.face.DeviceAuthRecord;
7   -import com.sincere.haikangface.bean.face.SendFaceDto;
  7 +import com.sincere.haikangface.bean.face.SendFaceBean;
8 8 import com.sincere.haikangface.dao.UserDao;
9 9 import com.sincere.haikangface.service.UserOperateService;
10   -import com.sincere.haikangface.utils.JsonUtils;
11 10 import io.swagger.annotations.ApiOperation;
12 11 import lombok.extern.slf4j.Slf4j;
13 12 import org.springframework.beans.factory.annotation.Autowired;
14 13 import org.springframework.http.MediaType;
  14 +import org.springframework.validation.annotation.Validated;
15 15 import org.springframework.web.bind.annotation.*;
16 16 import org.springframework.web.multipart.MultipartFile;
17 17  
... ... @@ -65,11 +65,14 @@ public class UserOperateController {
65 65 return userOperateService.againSendFace(userId,deviceId,userType);
66 66 }
67 67  
68   - @ApiOperation(value = "照片下发2.0")
69   - @RequestMapping(value = "sendFaceByThread", method = RequestMethod.POST)
70   - public Result sendFaceByThread(@RequestBody SendFaceDto sendFaceDto,
71   - @RequestParam(value = "groupId",required = false) Integer groupId) {
72   - return userOperateService.sendUserFaceByThread(sendFaceDto,groupId);
  68 + @ApiOperation(value = "补发单个人脸至指定设备2.0")
  69 + @RequestMapping(value = "againNoSendOneFace", method = RequestMethod.POST)
  70 + public Result againNoSendOneFace(@RequestParam(value = "file",required = false) MultipartFile file,
  71 + @RequestParam("schoolId") Integer schoolId,
  72 + @RequestParam("cardNum") String cardNum,
  73 + @RequestParam("userType") Integer userType,
  74 + @RequestParam("deviceIds") String deviceIds) {
  75 + return userOperateService.againNoSendOneFace(file,schoolId,cardNum,userType,deviceIds);
73 76 }
74 77  
75 78 @ApiOperation(value = "删除下发失败人脸2.0")
... ... @@ -80,40 +83,14 @@ public class UserOperateController {
80 83  
81 84 @RequestMapping(value = "sendFailFace", method = RequestMethod.POST)
82 85 @ApiOperation(value = "重新下发失败人脸2.0")
83   - public Result sendFailFace(@RequestParam("schoolId") Integer schoolId) {
84   - return userOperateService.sendFailFace(schoolId);
85   - }
86   -
87   - @RequestMapping(value = "sendFailFace2", method = RequestMethod.POST)
88   - @ApiOperation(value = "重新下发失败人脸2.1")
89   - public Result sendFailFace(@RequestParam("schoolId") Integer schoolId,
90   - @RequestParam(value = "deviceIds",required = false) String deviceIds) {
91   - return userOperateService.sendFailFace2(schoolId,deviceIds);
  86 + public Result sendFailFace(@Validated @RequestBody SendFaceBean faceBean) {
  87 + return userOperateService.sendFailFace(faceBean);
92 88 }
93 89  
94 90 @ApiOperation(value = "删除指定人脸2.0")
95 91 @RequestMapping(value = "deleteFace", method = RequestMethod.POST)
96   - public Result deleteFace(@RequestParam("schoolId") Integer schoolId, @RequestParam("cards") String cards,
97   - @RequestParam(value = "deviceIds",required = false) String deviceIds) {
98   - return userOperateService.deleteFace(schoolId,cards,deviceIds);
99   - }
100   -
101   - @ApiOperation(value = "下发未下发的人脸至指定设备2.0")
102   - @RequestMapping(value = "sendFaceForNoSend", method = RequestMethod.POST)
103   - public Result sendFaceForNoSend(@RequestParam("schoolId") Integer schoolId,
104   - @RequestParam("userType") Integer userType,
105   - @RequestParam(value = "studentType",required = false) Integer studentType,
106   - @RequestParam(value = "sex",required = false) String sex,
107   - @RequestParam(value = "deviceIds",required = false) String deviceIds,
108   - @RequestParam(value = "groupId",required = false) Integer groupId) {
109   - return userOperateService.sendFaceForNoSend(schoolId,studentType,sex,userType,deviceIds,groupId);
110   - }
111   -
112   - @ApiOperation(value = "补发单个人脸至指定设备2.0")
113   - @RequestMapping(value = "againNoSendOneFace", method = RequestMethod.POST)
114   - public Result againNoSendOneFace(@RequestParam("file") MultipartFile file,@RequestParam("schoolId") Integer schoolId,
115   - @RequestParam("cardNum") String cardNum,@RequestParam("userType") Integer userType,@RequestParam("deviceIds") String deviceIds) {
116   - return userOperateService.againNoSendOneFace(file,schoolId,cardNum,userType,deviceIds);
  92 + public Result deleteFace(@Validated @RequestBody SendFaceBean faceBean) {
  93 + return userOperateService.deleteFace(faceBean);
117 94 }
118 95  
119 96 @ApiOperation(value = "捷安成闸机导入")
... ... @@ -122,71 +99,36 @@ public class UserOperateController {
122 99 return userOperateService.insertUpdateCard(cardNums);
123 100 }
124 101  
125   -
126   - @ApiOperation(value = "压缩包上传下发")
127   - @RequestMapping(value = "exportFace", method = RequestMethod.POST)
128   - public Result exportFace(@RequestParam("schoolId") Integer schoolId,
129   - @RequestParam("userType") Integer userType,
130   - @RequestParam("deviceIds") String deviceIds,
131   - @RequestParam("faceSrcPath") String faceSrcPath){
132   - return userOperateService.exportFace(schoolId,userType,deviceIds,faceSrcPath);
133   - }
134   -
135   - @ApiOperation(value = "按班级指定下发")
  102 + @ApiOperation(value = "按条件指定下发")
136 103 @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST)
137   - public Result sendFaceByClassId(@RequestParam("schoolId") Integer schoolId,
138   - @RequestParam(value = "classIds",required = false) String classIds,
139   - @RequestParam(value = "deviceIds",required = false) String deviceIds,
140   - @RequestParam(value = "studentType",required = false) Integer studentType,
141   - @RequestParam(value = "sex",required = false) String sex,
142   - @RequestParam(value = "isCheck",required = false) Integer isCheck){
143   - return userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds,studentType,sex,isCheck);
144   - }
145   -
146   - @ApiOperation(value = "按班级指定下发")
147   - @RequestMapping(value = "sendFaceByKeyword", method = RequestMethod.POST)
148   - public Result sendFaceByKeyword(@RequestParam("schoolId") Integer schoolId,
149   - @RequestParam(value = "deviceIds",required = false) String deviceIds,
150   - @RequestParam(value = "keyword",required = false) String keyword,
151   - @RequestParam(value = "studentType",required = false) Integer studentType,
152   - @RequestParam(value = "sex",required = false) String sex,
153   - @RequestParam(value = "isCheck",required = false) Integer isCheck){
154   - return userOperateService.sendFaceByKeyword(schoolId,deviceIds,keyword,studentType,sex,isCheck);
  104 + public Result sendFaceByClassId(@Validated @RequestBody SendFaceBean faceBean){
  105 + return userOperateService.sendFaceByClassId(faceBean);
155 106 }
156 107  
157   - @ApiOperation(value = "指定班级下发未下发人脸")
158   - @RequestMapping(value = "noSendByKeyword", method = RequestMethod.POST)
159   - public Result noSendByKeyword(@RequestParam("schoolId") Integer schoolId,
160   - @RequestParam(value = "keyword",required = false) String keyword,
161   - @RequestParam(value = "deviceIds",required = false) String deviceIds) {
162   - return userOperateService.noSendByKeyword(schoolId,keyword,deviceIds);
  108 + @ApiOperation(value = "按条件指定下发未发送")
  109 + @RequestMapping(value = "sendNuFaceByClassId", method = RequestMethod.POST)
  110 + public Result noSendByKeyword(@Validated @RequestBody SendFaceBean faceBean) {
  111 + return userOperateService.sendNuFaceByClassId(faceBean);
163 112 }
164 113  
165   - @ApiOperation(value = "根据宿舍分组下发")
  114 + @ApiOperation(value = "宿舍分组下发")
166 115 @RequestMapping(value = "sendFaceByRoomId", method = RequestMethod.POST)
167   - public Result sendFaceByRoomId(@RequestParam("schoolId") Integer schoolId,
168   - @RequestParam("roomId") Integer roomId,
169   - @RequestParam(value = "deviceIds",required = false) String deviceIds) {
170   - return userOperateService.sendFaceByRoomId(schoolId,roomId,deviceIds);
  116 + public Result sendFaceByRoomId(@Validated @RequestBody SendFaceBean faceBean) {
  117 + return userOperateService.sendFaceByRoomId(faceBean);
171 118 }
172 119  
173   - @ApiOperation(value = "删除指定学校下人脸照片")
174   - @RequestMapping(value = "deleteBySchoolId", method = RequestMethod.POST)
175   - public Result deleteBySchoolId(@RequestParam("schoolId") Integer schoolId,
176   - @RequestParam(value = "deviceIds",required = false) String deviceIds){
177   - return userOperateService.deleteFaceBySchoolId(schoolId,deviceIds);
  120 + @ApiOperation(value = "按条件删除学校下人脸照片")
  121 + @RequestMapping(value = "deleteByCondition", method = RequestMethod.POST)
  122 + public Result deleteByCondition(@Validated @RequestBody SendFaceBean faceBean){
  123 + return userOperateService.deleteByCondition(faceBean);
178 124 }
179 125  
180   - @RequestMapping(value = "checkFaceSend", method = RequestMethod.GET)
181   - public void checkFaceSend(){
182   - userOperateService.checkFaceSend();
183   - }
184   -
185   - @ApiOperation(value = "按班级指定下发")
186   - @RequestMapping(value = "replaceFaceByKeyword", method = RequestMethod.POST)
187   - public Result replaceFaceByKeyword(@RequestParam("schoolId") Integer schoolId,
188   - @RequestParam("deviceIds") String deviceIds,
189   - @RequestParam("keyword") String keyword){
190   - return userOperateService.replaceFaceByKeyword(schoolId,deviceIds,keyword);
  126 + @ApiOperation(value = "压缩包上传下发")
  127 + @RequestMapping(value = "exportFace", method = RequestMethod.POST)
  128 + public Result exportFace(@RequestParam("schoolId") Integer schoolId,
  129 + @RequestParam("userType") Integer userType,
  130 + @RequestParam("deviceIds") String deviceIds,
  131 + @RequestParam("faceSrcPath") String faceSrcPath){
  132 + return userOperateService.exportFace(schoolId,userType,deviceIds,faceSrcPath);
191 133 }
192 134 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
... ... @@ -12,27 +12,6 @@ import java.util.List;
12 12 @Repository
13 13 public interface UserDao {
14 14  
15   - /**
16   - * 没有记录取最新十条下发
17   - *
18   - * @return
19   - */
20   - @Select("select top (10) * from HS_StudentUpdateCard order by AddTime desc")
21   - List<StudentBean> getStudents();
22   -
23   - @Select("select student_num,name,studentcode from SZ_V_School_Student where school_id = 479")
24   - List<StudentBean> getStu();
25   -
26   - /**
27   - * 获取所有的学生
28   - *
29   - * @return
30   - */
31   - @Select("select * from HS_StudentUpdateCard where ID > #{id} and StudentType = #{StudentType} order by AddTime desc")
32   - List<StudentBean> getAllStudents(@Param("id") long id, @Param("StudentType") int StudentType);
33   - @Update("update SZ_V_School_Student set name = #{name} where student_id = #{student_id}")
34   - void updateTest(@Param("student_id") String student_id, @Param("name") String name);
35   -
36 15 @Select("select Top(1) student_num from SZ_V_School_Student where student_id = #{student_id} and role_state = 1")
37 16 String getStudent_Num(@Param("student_id") String student_id);
38 17  
... ... @@ -47,153 +26,9 @@ public interface UserDao {
47 26 @Param("KnowledgeId") String KnowledgeId, @Param("TestId") String TestId, @Param("ChapterId") String ChapterId, @Param("GradeId") String GradeId, @Param("SourceId") String SourceId,
48 27 @Param("OrderId") String OrderId, @Param("SId") String SId, @Param("StemId") String StemId, @Param("AutomaticCorrection") String AutomaticCorrection, @Param("SchoolId") String SchoolId);
49 28  
50   - @Select("select * from SZ_User where user_id = #{user_id}")
51   - UserBean getUser(@Param("user_id") String user_id);
52   -
53 29 @Select("select school_name from SZ_School where school_id = #{schoolid}")
54 30 String getSchoolName(@Param("schoolid") String schoolid);
55 31  
56   - @Select("select * from HS_ResFiles where UserId in(select user_id from SZ_V_School_Teacher where school_id = 1021)")
57   - List<FileBean> getFileRes();
58   -
59   - @Select("select * from HS_ResFiles where UserId = 'zy405704' and id >= 4476 ")
60   - List<FileBean> getFIlesReses();
61   -
62   - //
63   - @Select("(select Name from HS_ResGrade where SchoolId = 350 and id = #{id})")
64   - String getGradeName(@Param("id") String id);
65   -
66   - //
67   - @Select("select id from HS_ResGrade where SchoolId = 349 and name = #{name}")
68   - String getGradeId(@Param("name") String name);
69   -
70   - @Select("select * from HS_ResGrade where SchoolId = 350")
71   - List<HSGrade> getGrades();
72   -
73   -
74   - @Insert("insert into HS_ResGrade values (#{name},#{addTime},#{status},#{userId},#{schoolId},#{shortName},#{schoolYear},#{year},#{remark},#{isFinish})")
75   - void addGrade(@Param("name") String name, @Param("addTime") String addTime, @Param("status") int status, @Param("userId") String userId,
76   - @Param("schoolId") int schoolId, @Param("shortName") String shortName, @Param("schoolYear") int schoolYear, @Param("year") int year, @Param("remark") String remark, @Param("isFinish") int isFinish);
77   -
78   - //
79   - @Select("select * from HS_ResBook where SchoolId = 350")
80   - List<HS_ResBook> getHSResBook();
81   -
82   - @Insert(" insert into HS_ResBook values (#{name},#{addTime},#{status},#{userId},#{schoolId},#{press},#{pressTimes},#{price})")
83   - void addHSResBook(@Param("name") String name, @Param("addTime") String addTime, @Param("status") String status, @Param("userId") String userId, @Param("schoolId") String schoolId, @Param("press") String press,
84   - @Param("pressTimes") String pressTimes, @Param("price") String price);
85   -
86   - @Select("select * from SZ_Subject where school_id =350 and Status = 1")
87   - List<SubjectBean> getSubjects();
88   -
89   - @Insert("insert into SZ_Subject values(#{school_id},#{subject_name},#{intime},#{subId},#{isElective},#{status},#{typeId},#{maxPerson},#{shortName})")
90   - void addSubjectbean(@Param("school_id") int school_id, @Param("subject_name") String subject_name, @Param("intime") String intime,
91   - @Param("subId") int subId, @Param("isElective") int isElective, @Param("status") int status, @Param("typeId") int typeId, @Param("maxPerson") int maxPerson, @Param("shortName") String shortName);
92   -
93   - @Select("select Top(1)subject_id from SZ_Subject where subject_name = #{subject_name} and school_id = 349")
94   - String getSubjectId(@Param("subject_name") String subject_name);
95   -
96   - @Select("select Top(1) subject_name from SZ_Subject where subject_id = #{subject_id} and school_id = 350")
97   - String getSubjectName(@Param("subject_id") int subject_id);
98   -
99   - @Select("select Top(1) name from HS_ResBook where SchoolId = 350 and id = #{id}")
100   - String getBookName(@Param("id") int bookId);
101   -
102   - @Select("select Top(1) id from HS_ResBook where SchoolId = 349 and name = #{name}")
103   - int getBookId(@Param("name") String bookName);
104   -
105   - @Select("select id from HS_ResBookVersion where SchoolId = #{SchoolId}")
106   - List<String> getbookversionId(@Param("SchoolId") String SchoolId);
107   -
108   - @Select("select * from HS_ResChapter where SchoolId = 350")
109   - List<HS_ResChapter> getChapters();
110   -
111   - //
112   - @Select(" select * from HS_ResBookVersion where SchoolId = 350")
113   - List<HS_ResBookVersion> getResBookVersion();
114   -
115   - @Insert("insert into HS_ResBookVersion values(#{bookId},#{gradeId},#{subjectId},#{isUse},#{state},#{intime},#{schoolId})")
116   - void addResBookVersion(@Param("bookId") int bookId, @Param("gradeId") int gradeId, @Param("subjectId") int subjectId, @Param("isUse") int isUse, @Param("state") int state,
117   - @Param("intime") String intime, @Param("schoolId") int schoolId);
118   -
119   - @Insert("insert into HS_ResChapter values(#{name},#{subjectId},#{gradeId},#{pid},#{jiaoCaiId},#{bookVersionId},#{sort},#{type},#{addTime},#{status},#{userId},#{schoolId})")
120   - void addChapter(@Param("name") String name, @Param("subjectId") int subjectId, @Param("gradeId") int gradeId, @Param("pid") int pid, @Param("jiaoCaiId") int jiaoCaiId, @Param("bookVersionId") int bookVersionId,
121   - @Param("sort") int sort, @Param("type") int type, @Param("addTime") String addTime, @Param("status") int status, @Param("userId") String userId, @Param("schoolId") int schoolId);
122   -
123   - @Select("Select Top(1)name from HS_ResChapter where id = #{pid} ")
124   - String getChapterName(@Param("pid") int pid);
125   -
126   - @Select(" Select Top(1)id from HS_ResChapter where name=#{name} and SchoolId = 349")
127   - String getChapterId(@Param("name") String name);
128   -
129   - @Update("update HS_ResChapter set Pid = #{pid} where SchoolId = 349 and userId = #{userId} and name = #{name}")
130   - void updateChapter(@Param("userId") String userId, @Param("name") String name, @Param("pid") String chapterId);
131   -
132   - @Select("select id from HS_ResBook where SchoolId = 885 and name =(select name from HS_ResBook where SchoolId = 1021 and Id = #{id})")
133   - String getJiaoCaiId(@Param("id") int id);
134   -
135   - @Select("select id from HS_ResCatalog where SchoolId = 885 and name = #{name}")
136   - String getResCatalog(@Param("name") String name);
137   -
138   - @Select("select name from HS_ResCatalog where SchoolId = 1021 and id = #{id}")
139   - String getResCatalogName(@Param("id") String id);
140   -
141   - @Select("select id from HS_ResType where SchoolId = 885 and name = #{name}")
142   - String getResType(@Param("name") String name);
143   -
144   - @Select("select name from HS_ResType where SchoolId = 1021 and id = #{id}")
145   - String getResTypeName(@Param("id") String id);
146   -
147   - //
148   - @Insert("insert into HS_ResFiles values(#{name},#{catalogId},#{typeId},#{gradeId},#{subjectId},#{jiaoCaiId},#{charpId},#{fileUrl},#{descript},#{keywords}" +
149   - ",#{addTime},#{status},#{userId},#{targetUrl},#{clicks},#{userList},#{isShare},#{charpId1},#{knowledgeId})")
150   - void addFiles(@Param("name") String name, @Param("catalogId") String catalogId, @Param("typeId") int typeId, @Param("gradeId") int gradeId,
151   - @Param("subjectId") int subjectId, @Param("jiaoCaiId") int jiaoCaiId, @Param("charpId") int charpId, @Param("fileUrl") String fileUrl,
152   - @Param("descript") String descript, @Param("keywords") String keywords, @Param("addTime") String addTime, @Param("status") int status,
153   - @Param("userId") String userId, @Param("targetUrl") String targetUrl, @Param("clicks") int clicks, @Param("userList") String userList, @Param("isShare") int isShare,
154   - @Param("charpId1") int charpId1, @Param("knowledgeId") int knowledgeId);
155   -
156   - @Select("select *\n" +
157   - "from SZ_V_School_Student where name = #{name} and school_id = #{school_id}")
158   - List<StudentBean> getAllStudentsWithSchoolId(@Param("school_id") String school_id, @Param("name") String name);
159   -
160   - @Select("select * from SZ_V_School_Student where school_id = #{school_id} and student_type = 2")
161   - List<StudentBean> getAllStuWithSchoolId(@Param("school_id") String school_id);
162   -
163   - @Select(" select * from SZ_V_School_Student where school_id = 562 and student_num is not null and photo is not null and len(photo)>0")
164   - List<StudentInfo> getAllStus();
165   -
166   - @Select("select user_id\n" +
167   - "from SZ_V_School_Student where school_id = 13 and student_type =2 and len(student_num)=0\n")
168   - List<String> getUserids();
169   -
170   - @Insert("insert into HS_ResRalation (FileId,AddTime,UserId) values (#{FileId},#{AddTime},#{userId})")
171   - void addRelation(@Param("FileId") String id, @Param("AddTime") String time, @Param("userId") String userId);
172   -
173   - @Select("select student_id from SZ_V_School_Student where school_id = #{s} and name = #{name}")
174   - List<String> getStudentIdWidthName(@Param("name") String trim, @Param("s") String s);
175   -
176   - @Insert("insert into Virtual_Card values(#{intCardNum},#{i},#{cardNum})")
177   - void addVirtual_Card(@Param("intCardNum") long intCardNum, @Param("i") int i, @Param("cardNum") String cardNum);
178   -
179   - @Select("select class_id from SZ_V_School_Student where school_id = 479 and student_id = #{customerId} ")
180   - String getClassName(@Param("customerId") String customerId);
181   -
182   - @Select("select clint_id from SZ_Attendance where school_id = #{schoolId} and clint_type=18")
183   - List<String> getDeviceIdsWidthSchoolId(@Param("schoolId") int schoolId);
184   -
185   -
186   - @Select("select StudentId from SS_RoomNumber where Pid in (select id\n" +
187   - " from SS_Room\n" +
188   - " where SchoolId = 479 and SS_Room.Pid =10284 )")
189   - List<String> getStudentIdWithRoom();
190   -
191   - @Select("select CardNum from Virtual_Card where state =0 and id < 5475 ;")
192   - List<String> getVirCards();
193   -
194   - @Update("update SZ_V_School_Student set student_num =#{student_num} where school_id = 13 and student_type =2 and len(student_num)=0 and user_id = #{user_id}")
195   - void updateStuCards(@Param("student_num") String card, @Param("user_id") String user_id);
196   -
197 32  
198 33 @Select("select Top(1) * from SZ_V_School_Student where studentcode = #{studentcode} and school_id = #{schoolId}")
199 34 StudentBean getStudentWithstudentcode(@Param("studentcode") String studentcode, @Param("schoolId") String schoolId);
... ... @@ -210,18 +45,6 @@ public interface UserDao {
210 45 void addWGTem(@Param("UserId") String UserId, @Param("StudentId") String StudentId, @Param("Name") String Name, @Param("ClassId") String ClassId,
211 46 @Param("ClassName") String ClassName, @Param("Temperature") String Temperature, @Param("Type") String Type, @Param("SchoolId") String SchoolId, @Param("Intime") String Intime);
212 47  
213   - @Select("select student_num from SZ_V_School_Student where school_id = #{schoolId} and student_num<>''")
214   - List<String> getStudentCardsWidthSchoolId(@Param("schoolId") int schoolId);
215   -
216   - @Select("select student_num from SZ_V_School_Teacher where school_id = #{schoolId} and student_num<>''")
217   - List<String> getTeaCardsWidthSchoolId(@Param("schoolId") String schoolId);
218   -
219   - @Select("select Top(1) teacher_num from SZ_V_School_Teacher where user_id = #{userId}")
220   - String getTeaCardWithUserId(@Param("userId") String userId);
221   -
222   - @Select("select Top(1) student_num from SZ_V_School_Student where school_id = #{schoolId} and user_id = #{userId}")
223   - String getStudentCardWithUserId(@Param("schoolId") String schoolId,@Param("userId") String userId);
224   -
225 48 @Select("select Top(1) studentcode from SZ_V_School_Student where student_num = #{num}")
226 49 String getStudentCode(@Param("num") String num);
227 50  
... ... @@ -274,14 +97,9 @@ public interface UserDao {
274 97 @Param("groupId")Integer groupId);
275 98  
276 99 List<StudentBean> getStudentByClassId(@Param("schoolId") int schoolId,
277   - @Param("classIds") List<Integer> classIds,
278   - @Param("sexList") List<Integer> sexList,
279   - @Param("studentType")Integer studentType);
280   -
281   - List<StudentBean> getStudentByKeyword(@Param("schoolId") int schoolId,
282   - @Param("keyword") String keyword,
283   - @Param("sexList") List<Integer> sexList,
284   - @Param("studentType")Integer studentType);
  100 + @Param("studentType") Integer studentType,
  101 + @Param("classIds") List<String> classIds,
  102 + @Param("sexList") List<String> sexList);
285 103  
286 104 List<String> getDeviceIds(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId);
287 105  
... ... @@ -292,7 +110,7 @@ public interface UserDao {
292 110 @Select(" select top 1* from SZ_V_School_Student where student_id = #{student_id}")
293 111 StudentBean getStudentWithid(@Param("student_id") String student_id);
294 112  
295   - StudentBean getStudentCByUserId(@Param("userId") String userId,@Param("schoolId") Integer schoolId);
  113 + StudentBean getStudentByUserId(@Param("userId") String userId,@Param("schoolId") Integer schoolId);
296 114  
297 115 StudentBean getTeacherByUserId(@Param("userId") String userId,@Param("schoolId") Integer schoolId);
298 116  
... ... @@ -302,16 +120,11 @@ public interface UserDao {
302 120  
303 121 void insertCard(UpdateCardBean bean);
304 122  
305   - void insertStudent(SaveStudentBak studentBak);
306   -
307   - void updateStudent(@Param("id") Integer id);
308   -
309   - List<SaveStudentBak> selectStudentList();
310   -
311 123 List<Integer> getRoomBySchoolId(@Param("schoolId") Integer schoolId,@Param("groupId") Integer groupId);
312 124  
313 125 List<StudentBean> getStudentByRoomIds(@Param("schoolId") Integer schoolId,@Param("pIdList") List<Integer> pIdList);
314 126  
  127 + /***找回已毕业的数据***/
315 128 List<StudentBean> getTestVsByKeyword(@Param("schoolId") int schoolId,
316 129 @Param("keyword") String keyword,
317 130 @Param("sexList") List<Integer> sexList,
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java
... ... @@ -3,7 +3,10 @@ package com.sincere.haikangface.service;
3 3 import com.sincere.haikangface.bean.Result;
4 4 import com.sincere.haikangface.bean.face.AuthRecordDto;
5 5 import com.sincere.haikangface.bean.face.DeviceAuthRecord;
  6 +import com.sincere.haikangface.bean.face.SendFaceBean;
6 7 import com.sincere.haikangface.bean.face.SendFaceDto;
  8 +import org.springframework.validation.annotation.Validated;
  9 +import org.springframework.web.bind.annotation.RequestBody;
7 10 import org.springframework.web.multipart.MultipartFile;
8 11  
9 12 /**
... ... @@ -52,13 +55,6 @@ public interface UserOperateService {
52 55 Result againSendFace(String userId,String deviceId,Integer userType);
53 56  
54 57 /**
55   - * 多线程照片下发
56   - * @param sendFaceDto
57   - * @return
58   - */
59   - Result sendUserFaceByThread(SendFaceDto sendFaceDto,Integer groupId);
60   -
61   - /**
62 58 * 删除失败表人脸
63 59 * @param schoolId
64 60 * @return
... ... @@ -67,31 +63,15 @@ public interface UserOperateService {
67 63  
68 64 /**
69 65 * 下发失败表人脸
70   - * @param schoolId
71 66 * @return
72 67 */
73   - Result sendFailFace(Integer schoolId);
74   -
75   - Result sendFailFace2(Integer schoolId,String deviceIds);
  68 + Result sendFailFace(SendFaceBean faceBean);
76 69  
77 70 /**
78 71 * 删除指定人脸
79   - * @param schoolId
80   - * @param cards
81   - * @param deviceIds
82 72 * @return
83 73 */
84   - Result deleteFace(Integer schoolId,String cards,String deviceIds);
85   -
86   - /**
87   - * 下发未下发完的人脸,仅供测试使用
88   - * @param schoolId
89   - * @param studentType
90   - * @param sex
91   - * @param deviceIds
92   - * @return
93   - */
94   - Result sendFaceForNoSend(Integer schoolId,Integer studentType,String sex,Integer userType,String deviceIds,Integer groupId);
  74 + Result deleteFace(SendFaceBean faceBean);
95 75  
96 76 /**
97 77 * 补发单个人脸至指定设备
... ... @@ -112,57 +92,40 @@ public interface UserOperateService {
112 92 Result insertUpdateCard(String cardNums);
113 93  
114 94 /**
115   - * 压缩包上传下发人脸
116   - * @param schoolId
117   - * @param userType
118   - * @param deviceIds
119   - * @param faceSrcPath
  95 + *
  96 + * @param faceBean
120 97 * @return
121 98 */
122   - Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath);
  99 + Result sendFaceByClassId(SendFaceBean faceBean);
123 100  
124 101 /**
125   - * 按班级下发人脸
126   - * @param schoolId
127   - * @param classIds
128   - * @param deviceIds
129   - * @param isCheck
  102 + *
  103 + * @param faceBean
130 104 * @return
131 105 */
132   - Result sendFaceByClassId(Integer schoolId,String classIds,String deviceIds,Integer studentType,String sex,Integer isCheck);
  106 + Result sendNuFaceByClassId(SendFaceBean faceBean);
133 107  
134 108 /**
135   - * 根据班级新生班级关键字下发
136   - * @param schoolId
137   - * @param deviceIds
138   - * @param keyword
139   - * @param studentType
140   - * @param sex
141   - * @param isCheck
  109 + * 根据寝室号下发人脸
  110 + * @param faceBean
142 111 * @return
143 112 */
144   - Result sendFaceByKeyword(Integer schoolId,String deviceIds,String keyword,Integer studentType,String sex,Integer isCheck);
145   -
146   - Result noSendByKeyword(Integer schoolId,String keyword,String deviceIds);
  113 + Result sendFaceByRoomId(SendFaceBean faceBean);
147 114  
148 115 /**
149   - * 根据寝室号下发人脸
150   - * @param schoolId
151   - * @param groupId
152   - * @param deviceIds
  116 + * 删除指定学校下的人脸
  117 + * @param faceBean
153 118 * @return
154 119 */
155   - Result sendFaceByRoomId(Integer schoolId,Integer groupId,String deviceIds);
  120 + Result deleteByCondition(SendFaceBean faceBean);
156 121  
157 122 /**
158   - * 删除指定学校下的人脸
  123 + * 压缩包上传下发人脸
159 124 * @param schoolId
  125 + * @param userType
160 126 * @param deviceIds
  127 + * @param faceSrcPath
161 128 * @return
162 129 */
163   - Result deleteFaceBySchoolId(Integer schoolId,String deviceIds);
164   -
165   - void checkFaceSend();
166   -
167   - Result replaceFaceByKeyword(Integer schoolId,String deviceIds,String keyword);
  130 + Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath);
168 131 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java
... ... @@ -8,6 +8,7 @@ import com.sincere.haikangface.async.SendUserAsync;
8 8 import com.sincere.haikangface.bean.AttendanceBean;
9 9 import com.sincere.haikangface.bean.SendRecordBean;
10 10 import com.sincere.haikangface.bean.StudentBean;
  11 +import com.sincere.haikangface.bean.face.SendFaceBean;
11 12 import com.sincere.haikangface.dao.DeviceDao;
12 13 import com.sincere.haikangface.dao.UserDao;
13 14 import com.sincere.haikangface.enums.EnumSzBusinessType;
... ... @@ -23,9 +24,12 @@ import org.springframework.stereotype.Service;
23 24 import org.springframework.util.CollectionUtils;
24 25  
25 26 import java.io.File;
  27 +import java.io.FileInputStream;
  28 +import java.io.FileOutputStream;
26 29 import java.text.SimpleDateFormat;
27 30 import java.util.*;
28 31 import java.util.concurrent.*;
  32 +import java.util.function.Function;
29 33 import java.util.stream.Collectors;
30 34  
31 35 /**
... ... @@ -276,29 +280,22 @@ public class BaseService {
276 280  
277 281 @Async
278 282 public void sendUserFaceByAsyncThread(Integer schoolId,Integer userType,List<StudentBean> studentBeanList,List<String> deviceList){
279   - List<String> deviceId_100 = new ArrayList<>();
280   - List<String> deviceId_253 = new ArrayList<>();
  283 + List<String> deviceId100 = new ArrayList<>();
  284 + List<String> deviceId253 = new ArrayList<>();
281 285 //过滤设备
282 286 for (String sno : deviceList) {
283 287 //若100服务器有此设备再进行多线程执行下发人脸任务,否则请求253服务执行单个下发人脸
284   - if (cmsServer.getIsDeviceOnline(sno)) {
285   - deviceId_100.add(sno);
286   - }else{
287   - deviceId_253.add(sno);
288   - }
289   - }
290   - if(deviceId_100.size()>0){
291   - //100服务器
292   - sendFaceToDevice100(deviceId_100,studentBeanList,schoolId,userType);
293   - }
294   - if(deviceId_253.size()>0){
295   - //253服务器
296   - sendFaceToDevice253(deviceId_253,studentBeanList,schoolId,userType);
  288 + if (cmsServer.getIsDeviceOnline(sno)) deviceId100.add(sno);
  289 + else deviceId253.add(sno);
297 290 }
  291 + //100服务器
  292 + sendFaceToDevice100(deviceId100,studentBeanList,schoolId,userType);
  293 + //253服务器
  294 + sendFaceToDevice253(deviceId100,studentBeanList,schoolId,userType);
298 295 }
299 296  
300 297  
301   - protected void sendFaceToDevice100(List<String> deviceIds,List<StudentBean> studentBeanList,Integer schoolId,Integer userType){
  298 + protected void sendFaceToDevice100(List<String> deviceIds,List<StudentBean> studentList,Integer schoolId,Integer userType){
302 299 log.info("------------------------开始执行100服务,人脸照下发---------------------");
303 300 String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
304 301 Calendar calendar = Calendar.getInstance();
... ... @@ -306,64 +303,41 @@ public class BaseService {
306 303 String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
307 304 //下发标识:详情见枚举 EnumHkOperateType
308 305 int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code;
309   - for(StudentBean studentBean : studentBeanList){
  306 + studentList.stream().forEach(s->{
310 307 try{
311   - String userName= studentBean.getName();
312   - String userId = studentBean.getUser_id();
313   - String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
314   - String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num();
315   - String typeName=userType.intValue()==1?"Teacher":"Student";
316   - if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){
317   - continue;
318   - }
319   - //以学籍号为名的文件名
320   - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
321   - //100服务器人脸照绝对路径
322   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
323   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
324   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
325   - String filePath="";
326   - if(photo.indexOf("f0i5l7e5")!=-1){
327   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
328   - filePath= path_3 + afterStr;
329   - }
330   - if(photo.indexOf("face17e5")!=-1){
331   - filePath = path_2 + "\\" + fileName;
332   - }
333   - if(photo.indexOf("face17e50")!=-1){
334   - filePath = path_1 + "\\" + fileName;
  308 + String userName = s.getName();
  309 + String studentNum = s.getStudent_num();
  310 + String filePath = this.checkUserFace(s,userType,schoolId);
  311 + if(StringUtils.isBlank(filePath)) return;
  312 + File file = new File(filePath);
  313 + if(!file.exists()) return;
  314 + String targetPath = FileUtils.picPathComp + file.getName();
  315 + try {
  316 + CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
  317 + } catch (Exception e) {
  318 + log.error("压缩图片失败:",e);
  319 + return;
335 320 }
336   - File file = new File(filePath);//图片
337   - if(file.exists()){
338   - String targetPath = FileUtils.picPathComp + file.getName();
339   - try {
340   - CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
341   - } catch (Exception e) {
342   - log.error("压缩图片失败:",e);
343   - continue;
344   - }
345   - for(String sno : deviceIds){
346   - if(sendRecordDao.getRecordIsExit(sno,cardNum,userId).size()<1){
347   - if(cmsServer.getIsDeviceOnline(sno)){
348   - if(!StringUtils.isBlank(cardNum)){
349   - String cardNumLong = Long.parseLong(getCard(cardNum),16) + "";
350   - //下发100海康设备
351   - sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, validTimeEnabled, userName, sno, String.valueOf(userType),schoolId,cardNum);
352   - }
353   - }else{
354   - log.error("100服务器,设备不在线");
355   - }
  321 + for(String sno : deviceIds){
  322 + if(cmsServer.getIsDeviceOnline(sno)){
  323 + if(!StringUtils.isBlank(s.getStudent_num())){
  324 + String cardNumLong = Long.parseLong(getCard(studentNum),16) + "";
  325 + //下发100海康设备
  326 + sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime,
  327 + validTimeEnabled, userName, sno, String.valueOf(userType),schoolId,studentNum);
356 328 }
  329 + }else{
  330 + log.error("100服务器,设备不在线");
357 331 }
358 332 }
359 333 }catch (Exception e){
360 334 log.error("人脸下发失败,异常信息:",e);
361   - continue;
  335 + return;
362 336 }
363   - }
  337 + });
364 338 }
365 339  
366   - protected void sendFaceToDevice253(List<String> deviceIds,List<StudentBean> studentBeanList,Integer schoolId,Integer userType){
  340 + protected void sendFaceToDevice253(List<String> deviceIds,List<StudentBean> studentList,Integer schoolId,Integer userType){
367 341 log.info("------------------------开始执行253服务,人脸照下发---------------------");
368 342 String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
369 343 Calendar calendar = Calendar.getInstance();
... ... @@ -371,73 +345,31 @@ public class BaseService {
371 345 String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
372 346 //下发标识:详情见枚举 EnumHkOperateType
373 347 int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code;
374   - for(StudentBean studentBean : studentBeanList){
  348 + studentList.stream().forEach(s->{
375 349 try{
376   - String userName= studentBean.getName();
377   - String userId = studentBean.getUser_id();
378   - String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
379   - String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num();
380   - String typeName=userType.intValue()==1?"Teacher":"Student";
381   - if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){
382   - continue;
383   - }
384   - //以学籍号为名的文件名
385   - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
386   - //100服务器人脸照绝对路径
387   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
388   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
389   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
390   - String filePath="";
391   - if(photo.indexOf("f0i5l7e5")!=-1){
392   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
393   - filePath= path_3 + afterStr;
394   - }
395   - if(photo.indexOf("face17e5")!=-1){
396   - filePath = path_2 + "\\" + fileName;
397   - }
398   - if(photo.indexOf("face17e50")!=-1){
399   - filePath = path_1 + "\\" + fileName;
  350 + String userName = s.getName();
  351 + String studentNum = s.getStudent_num();
  352 + String filePath = this.checkUserFace(s,userType,schoolId);
  353 + if(StringUtils.isBlank(filePath)) return;
  354 + File file = new File(filePath);
  355 + if(!file.exists()) return;
  356 + String targetPath = FileUtils.picPathComp + file.getName();
  357 + try {
  358 + CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
  359 + } catch (Exception e) {
  360 + log.error("压缩图片失败:",e);
  361 + return;
400 362 }
401   - File file = new File(filePath);//图片
402   - if(file.exists()) {
403   - String targetPath = FileUtils.picPathComp + file.getName();
404   - try {
405   - CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
406   - } catch (Exception e) {
407   - log.error("压缩图片失败:", e);
408   - continue;
409   - }
410   - for (String sno : deviceIds) {
411   - if(sendRecordDao.getRecordIsExit(sno,cardNum,userId).size()<1){
412   - //下发253服务器
413   - sendUserAsync.uploadImgs(targetPath,cardNum, userName, sno, startTime, endTime, validTimeEnabled, String.valueOf(userType),schoolId);
414   - }
415   - }
  363 + for (String sno : deviceIds) {
  364 + //下发253服务器
  365 + sendUserAsync.uploadImgs(targetPath,studentNum, userName, sno, startTime, endTime, validTimeEnabled,
  366 + String.valueOf(userType),schoolId);
416 367 }
417 368 }catch (Exception e){
418   - log.error("人脸下发失败");
419   - e.printStackTrace();
420   - continue;
  369 + log.error("人脸下发失败",e);
  370 + return;
421 371 }
422   - }
423   - }
424   -
425   -
426   - /**
427   - * 获取指定学校下的学生卡信息
428   - * @param schoolId
429   - * @return
430   - */
431   - public List<SendRecordBean> getRecordCardBySchoolId(int schoolId) {
432   - List<SendRecordBean> allStudents = new LinkedList<>();
433   - List<SendRecordBean> students = sendRecordDao.getSendFaceSuccess(schoolId);
434   - allStudents.addAll(students);
435   - List<SendRecordBean> students2 = sendRecordDao.getFaceRecord(schoolId);
436   - allStudents.addAll(students2);
437   - //去重重复数据
438   - List<SendRecordBean> studentList = allStudents.stream().collect(Collectors.collectingAndThen(
439   - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SendRecordBean::getNum))),ArrayList::new));
440   - return studentList;
  372 + });
441 373 }
442 374  
443 375 /**
... ... @@ -480,43 +412,12 @@ public class BaseService {
480 412  
481 413 /**
482 414 * 根据班级ID获取对应班级下的学生数据信息
483   - * @param schoolId
484   - * @param classIds
485 415 * @return
486 416 */
487   - public List<StudentBean> getStudentByClassId(Integer schoolId,String classIds,Integer studentType,String sex) {
488   - List<Integer> classList = null;
489   - if(StringUtils.isNotBlank(classIds)){
490   - classList = Arrays.asList(classIds.split(","))
491   - .stream().map(Integer::parseInt).collect(Collectors.toList());
492   - }
493   - List<Integer> sexList = null;
494   - if(StringUtils.isNotBlank(sex)){
495   - sexList = Arrays.asList(sex.split(","))
496   - .stream().map(Integer::parseInt).collect(Collectors.toList());
497   - }
498   - List<StudentBean> students = userDao.getStudentByClassId(schoolId,classList,sexList,studentType);
499   - //去重重复数据
500   - List<StudentBean> studentList = students.stream().collect(Collectors.collectingAndThen(
501   - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
502   - return studentList;
503   - }
504   -
505   - /**
506   - * 根据班级关键字获取学生数据信息
507   - * @param schoolId
508   - * @param keyword
509   - * @param studentType
510   - * @param sex
511   - * @return
512   - */
513   - public List<StudentBean> getStudentByKeyword(Integer schoolId,String keyword,Integer studentType,String sex) {
514   - List<Integer> sexList = null;
515   - if(StringUtils.isNotBlank(sex)){
516   - sexList = Arrays.asList(sex.split(","))
517   - .stream().map(Integer::parseInt).collect(Collectors.toList());
518   - }
519   - List<StudentBean> students = userDao.getStudentByKeyword(schoolId,keyword,sexList,studentType);
  417 + public List<StudentBean> getStudentByClassId(SendFaceBean faceBean) {
  418 + List<String> classList = faceBean.getClassList();
  419 + List<String> sexList = faceBean.getSexList();
  420 + List<StudentBean> students = userDao.getStudentByClassId(faceBean.getSchoolId(),faceBean.getStudentType(),classList,sexList);
520 421 //去重重复数据
521 422 List<StudentBean> studentList = students.stream().collect(Collectors.collectingAndThen(
522 423 Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
... ... @@ -555,7 +456,7 @@ public class BaseService {
555 456 List<Integer> pIdlIst = rooms.stream().distinct().collect(Collectors.toList());
556 457 List<StudentBean> studentBeans = userDao.getStudentByRoomIds(schoolId,pIdlIst);
557 458 //去重重复数据
558   - List<StudentBean> studentList = studentBeans.stream().collect(Collectors.collectingAndThen(
  459 + List<StudentBean> studentList = studentBeans.parallelStream().collect(Collectors.collectingAndThen(
559 460 Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
560 461 return studentList;
561 462 }
... ... @@ -576,34 +477,20 @@ public class BaseService {
576 477 return teacherist;
577 478 }
578 479  
579   -
580   - public void getSuccessList(Integer schoolId,String deviceIds) {
581   - //下发设备集合
582   - String[] deviceArr = deviceIds.split(",");
583   - List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr));
584   - if(deviceList.size()<1){
585   - return;
586   - }
587   - //启用多线程执行
588   - CountDownLatch begin = new CountDownLatch(1);
589   - CountDownLatch end = new CountDownLatch(deviceList.size());
590   - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-sendFace-runner-%d").build();
591   - ExecutorService exe = new ThreadPoolExecutor(8,16,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(),namedThreadFactory);
592   - for(String sno : deviceList){
593   - exe.execute(new AsyncTask(userDao,sendRecordDao,schoolId,sno,begin,end));
594   - }
595   - begin.countDown();
596   - try {
597   - end.await();
598   - }catch (Exception e){
599   - log.error("迁移人脸照失败"+e);
600   - e.printStackTrace();
601   - }
602   - exe.shutdown();
603   - System.out.println("统计100服务器总共有"+deviceList.size()+"个设备,处理完毕");
  480 + /**
  481 + * 获取指定学校下的学生卡信息
  482 + * @return
  483 + */
  484 + public List<SendRecordBean> getSendRecordList(SendFaceBean faceBean) {
  485 + List<SendRecordBean> students = sendRecordDao.getSendRecordList(faceBean.getSchoolId(),faceBean.getDeviceList(),faceBean.getStatus());
  486 + //去重重复数据
  487 + List<SendRecordBean> studentList = students.stream().collect(Collectors.collectingAndThen(
  488 + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SendRecordBean::getNum))),ArrayList::new));
  489 + return studentList;
604 490 }
605 491  
606 492  
  493 +
607 494 public void clearStudent(Integer schoolId,String deviceIds) {
608 495 //下发设备集合
609 496 String[] deviceArr = deviceIds.split(",");
... ... @@ -637,7 +524,6 @@ public class BaseService {
637 524 System.out.println("size: " + sendRecordBeans.size());
638 525 for(String s : sendRecordBeans){
639 526 StudentBean studentBean = userDao.getStudentWithCard(s,schoolId);
640   -// System.out.println(new Gson().toJson(studentBean));
641 527 if(studentBean == null){
642 528 System.out.println(s);
643 529 sendRecordDao.deleteRecordByNum(schoolId,s);
... ... @@ -676,5 +562,58 @@ public class BaseService {
676 562 }
677 563  
678 564  
  565 + public List<String> getDeviceList(String deviceIds,Integer schoolId){
  566 + if(StringUtils.isNotBlank(deviceIds)) return Arrays.asList(deviceIds.split(","));
  567 + return deviceDao.selectDeviceBySchoolId(schoolId);
  568 + }
679 569  
  570 + public String checkUserFace(StudentBean studentBean,Integer userType,Integer schoolId){
  571 + String cardNum = userType.intValue()==1 ? studentBean.getTeacher_num():studentBean.getStudent_num();
  572 + String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
  573 + if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)) return null;
  574 + String typeName= userType.intValue()==1?"Teacher":"Student";
  575 + //以学籍号为名的文件名
  576 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
  577 + //100服务器人脸照绝对路径
  578 + String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
  579 + String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
  580 + String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
  581 + String filePath="";
  582 + if(photo.indexOf("face17e5")!=-1) filePath = path_2 + "\\" + fileName;
  583 + if(photo.indexOf("face17e50")!=-1) filePath = path_1 + "\\" + fileName;
  584 + if(filePath.indexOf("?v=")!=-1) filePath = filePath.split("\\?")[0];
  585 + if(photo.indexOf("f0i5l7e5")!=-1){
  586 + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
  587 + filePath = path_3 + afterStr;
  588 + }
  589 + return filePath;
  590 + }
  591 +
  592 + public static void copy(String srcPathStr, String desPathStr) {
  593 + //获取源文件的名称
  594 + try {
  595 + FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象
  596 + FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象
  597 + byte datas[] = new byte[1024*8];//创建搬运工具
  598 + int len = 0;//创建长度
  599 + while((len = fis.read(datas))!=-1)//循环读取数据
  600 + {
  601 + fos.write(datas,0,len);
  602 + }
  603 + fis.close();//释放资源
  604 + fis.close();//释放资源
  605 + }
  606 + catch (Exception e)
  607 + {
  608 + e.printStackTrace();
  609 + }
  610 + }
  611 +
  612 + public boolean checkSendRecord(List<SendRecordBean> sendRecords,String sno,Integer schoolId,String cardNum){
  613 + SendRecordBean record = sendRecords.stream().filter(s->Objects.equals(s.getDeviceID(),sno) &&
  614 + Objects.equals(s.getStatus(),1) && Objects.equals(s.getSchoolId(),schoolId) &&
  615 + Objects.equals(s.getNum(),cardNum)).findFirst().orElse(null);
  616 + if(Objects.nonNull(record)) return true;
  617 + return false;
  618 + }
680 619 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java
... ... @@ -6,7 +6,6 @@ import com.sincere.haikangface.CMSServer;
6 6 import com.sincere.haikangface.async.SendUserAsync;
7 7 import com.sincere.haikangface.bean.*;
8 8 import com.sincere.haikangface.bean.face.*;
9   -import com.sincere.haikangface.bean.test.SaveStudentBak;
10 9 import com.sincere.haikangface.dao.DeviceDao;
11 10 import com.sincere.haikangface.dao.UserDao;
12 11 import com.sincere.haikangface.enums.EnumSzBusinessType;
... ... @@ -22,11 +21,10 @@ import org.springframework.stereotype.Service;
22 21 import org.springframework.web.multipart.MultipartFile;
23 22  
24 23 import java.io.File;
25   -import java.io.FileInputStream;
26 24 import java.io.FileOutputStream;
27 25 import java.io.IOException;
28   -import java.text.SimpleDateFormat;
29 26 import java.util.*;
  27 +import java.util.function.Function;
30 28 import java.util.stream.Collectors;
31 29  
32 30 /**
... ... @@ -125,16 +123,10 @@ public class UserOperateServiceImpl implements UserOperateService {
125 123 @Override
126 124 public Result sendHKAuth(Integer authId) {
127 125 DeviceAuthRecord record = userDao.getAuthRecord(authId);
128   - if(record ==null){
129   - log.info("未查询到对应权限ID: {}, 权限计划。",authId);
130   - return ResultGenerator.genFailResult("未查询到对应下发权限计划");
131   - }
132   - //设备ID
133   - String[] deviceArr = record.getSno().split(",");
134   - List<String> devices= new ArrayList<>(Arrays.asList(deviceArr));
135   - if(CollectionUtils.isEmpty(devices)){
136   - return ResultGenerator.genFailResult("未选择权限计划下发设备。");
137   - }
  126 + if(Objects.isNull(record)) return ResultGenerator.genFailResult("未查询到对应下发权限计划");
  127 +
  128 + List<String> devices= Arrays.asList(record.getSno().split(","));
  129 + if(CollectionUtils.isEmpty(devices)) return ResultGenerator.genFailResult("未选择权限计划下发设备。");
138 130 //学生类型
139 131 Integer studentType = record.getStudentType();
140 132 //周计划详情
... ... @@ -188,54 +180,28 @@ public class UserOperateServiceImpl implements UserOperateService {
188 180 }
189 181  
190 182 @Override
191   - public Result againSendFace(String userId, String deviceId,Integer userType) {
192   - StudentBean studentBean = null;
193   - String cardNum ="";
194   - String photo ="";
195   - String studentCode = "";
196   - if(userType.intValue() ==1){
197   - studentBean = userDao.getTeacherByUserId(userId,null);
198   - cardNum = studentBean.getTeacher_num();
199   - photo = studentBean.getFace();
200   - studentCode = studentBean.getNum();
201   - }else{
202   - studentBean = userDao.getStudentCByUserId(userId,null);
203   - cardNum = studentBean.getStudent_num();
204   - photo = studentBean.getPhoto();
205   - studentCode = studentBean.getStudentCode();
206   - }
207   - if (studentBean == null) {
  183 + public Result againSendFace(String userId, String deviceId, Integer userType) {
  184 + StudentBean bean = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  185 + userDao.getStudentByUserId(userId,null) : userDao.getTeacherByUserId(userId,null);
  186 + if (Objects.isNull(bean)) {
208 187 log.error("下发人脸失败,userId: {},未查询到用户信息", userId);
209 188 return ResultGenerator.genSuccessResult("未查询到用户信息");
210 189 }
211   - Integer schoolId = studentBean.getSchool_id();
212   - String userName = studentBean.getName();
  190 + String cardNum = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  191 + bean.getStudent_num() : bean.getTeacher_num();
  192 + String photo = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  193 + bean.getPhoto() : bean.getFace();
  194 + String studentCode = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  195 + bean.getStudentCode() : bean.getNum();
  196 + Integer schoolId = bean.getSchool_id();
  197 + String userName = bean.getName();
213 198 String typeName = userType.intValue() ==1 ? "Teacher" : "Student";
214   - String[] fileNameStr =photo.split(typeName +"/");
  199 + String[] fileNameStr = photo.split(typeName +"/");
215 200 if(fileNameStr.length==0){
216 201 log.error("文件名为空,文件路径 :"+ photo);
217 202 return ResultGenerator.genSuccessResult("文件名为空");
218 203 }
219   - //以学籍号为名的文件名
220   - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
221   - //100服务器人脸照绝对路径
222   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
223   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
224   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
225   - String filePath="";
226   - if(photo.indexOf("f0i5l7e5")!=-1){
227   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
228   - filePath= path_3 + afterStr;
229   - }
230   - if(photo.indexOf("face17e5")!=-1){
231   - filePath = path_2 + "\\" + fileName;
232   - }
233   - if(photo.indexOf("face17e50")!=-1){
234   - filePath = path_1 + "\\" + fileName;
235   - }
236   - if(filePath.indexOf("?v=")!=-1){
237   - filePath = filePath.split("\\?")[0];
238   - }
  204 + String filePath = baseService.checkUserFace(bean,userType,schoolId);
239 205 //校验100服务文件存储地址上是否存在此人脸
240 206 File file = new File(filePath.trim());//图片
241 207 if (!file.exists()) {
... ... @@ -249,6 +215,7 @@ public class UserOperateServiceImpl implements UserOperateService {
249 215 CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
250 216 } catch (Exception e) {
251 217 log.error("压缩图片失败:",e);
  218 + return ResultGenerator.genFailResult("重新下发失败");
252 219 }
253 220 }
254 221 //设备类型
... ... @@ -264,87 +231,19 @@ public class UserOperateServiceImpl implements UserOperateService {
264 231 }
265 232 //2.重新下发
266 233 boolean isOk = baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId);
267   - if (isOk) {
268   - return ResultGenerator.genSuccessResult();
269   - } else {
270   - return ResultGenerator.genFailResult("重新下发失败");
271   - }
  234 + if (!isOk) return ResultGenerator.genFailResult("重新下发失败");
272 235 }
273 236 //下大华人脸
274 237 if(clintType.intValue()== 22 || clintType.intValue()== 29){
275 238 //下发单个人脸至大华设备
276 239 HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId);
277   - return ResultGenerator.genSuccessResult();
278 240 }
279 241 return ResultGenerator.genSuccessResult();
280 242 }
281 243  
282 244 @Override
283   - public Result sendUserFaceByThread(SendFaceDto sendFaceDto,Integer groupId) {
284   - //下发设备集合
285   - String[] deviceArr = sendFaceDto.getsNos().split(",");
286   - List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr));
287   - if(deviceList.size()<1){
288   - return ResultGenerator.genFailResult("未选择下发设备");
289   - }
290   - Integer schoolId = sendFaceDto.getSchoolId();
291   - Integer studentType = sendFaceDto.getStudentType();
292   - String sex = sendFaceDto.getSex();
293   - Integer userType = null;
294   - if(sendFaceDto.getType().intValue()==0 || sendFaceDto.getType().intValue()==1){
295   - userType = 2;
296   - }else{
297   - userType = 1;
298   - }
299   - //根据类型获取下发用户信息
300   - List<StudentBean> studentBeanList = null;
301   - if (userType == EnumSzBusinessType.EnumUserType.TEACHER.code) {
302   - studentBeanList = baseService.getTeacherList(schoolId);
303   - }
304   - if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId ==null) {
305   - studentBeanList = baseService.getStudentList(schoolId,studentType,sex);
306   - }else if(userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId !=null){
307   - studentBeanList = baseService.getStudentListByGroup(schoolId,studentType,sex,groupId);
308   - }
309   - log.info("统计共有下发用户数量:{}",studentBeanList.size());
310   - //设备类型
311   - Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0));
312   - if(clintType.intValue()== 22 || clintType.intValue()== 29){
313   - if(groupId ==null){
314   - //发送大华设备
315   - HttpUtil.uploadDHImg(String.valueOf(schoolId),userType,sendFaceDto.getsNos(),studentType,sex);
316   - }else{
317   - Integer finalUserType = userType;
318   - studentBeanList.stream().forEach(s->{
319   - String userId = s.getUser_id();
320   - deviceList.stream().forEach(deviceId ->{
321   - this.againSendFace(userId,deviceId, finalUserType);
322   - });
323   - });
324   - }
325   - }
326   - if(clintType.intValue()== 18 || clintType.intValue()== 28){
327   - //发送海康设备:异步执行
328   - baseService.sendUserFaceByAsyncThread(schoolId,userType,studentBeanList,deviceList);
329   - }
330   - int fileSize = studentBeanList.size();
331   - int clintNum = deviceList.size();
332   - //下发所用时长
333   - int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
334   - //下发截止时间
335   - String dateStr = baseService.getTime(fileSize,clintNum,timeLength);
336   - Map map = new HashMap();
337   - map.put("timeLength",timeLength);
338   - map.put("afterDate",dateStr);
339   - map.put("fileSize",fileSize);
340   - return ResultGenerator.genSuccessResult(objectMapper.toJson(map));
341   - }
342   -
343   - @Override
344 245 public Result deleteFailFace(Integer schoolId) {
345   - if(schoolId ==null){
346   - return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空");
347   - }
  246 + if(schoolId ==null) return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空");
348 247 List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId);
349 248 if(recordBeanList.size()>0){
350 249 for(SendRecordBean recordBean : recordBeanList){
... ... @@ -369,7 +268,6 @@ public class UserOperateServiceImpl implements UserOperateService {
369 268 HttpUtil.deleteDHFace(schoolId,cardNum,deviceId);
370 269 }
371 270 //删除成功记录
372   - sendRecordDao.deleteUserFaceSuccess(schoolId,cardNum,deviceId);
373 271 sendRecordDao.deleteRecord(schoolId,deviceId,cardNum);
374 272 }catch (Exception e){
375 273 log.error("删除失败人脸失败,异常信息:{}",e);
... ... @@ -381,414 +279,163 @@ public class UserOperateServiceImpl implements UserOperateService {
381 279 }
382 280  
383 281 @Override
384   - public Result sendFailFace(Integer schoolId) {
385   - if(schoolId ==null){
386   - return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空");
387   - }
388   - List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId);
389   - if(recordBeanList.size()>0){
390   - for(SendRecordBean recordBean : recordBeanList){
391   - try{
392   - //用户类型1老师2学生
393   - int userType = recordBean.getUserType();
394   - //人脸卡号
395   - String cardNum = recordBean.getNum();
396   - //设备ID、设备类型
397   - String deviceId = recordBean.getDeviceID();
398   - Integer clintType = userDao.getClintTypeByDeviceId(deviceId);
399   - //2.重新下发
400   - StudentBean studentBean= null;
401   - String typeName ="";
402   - String photo = "";
403   - if(userType ==1){
404   - typeName= "Teacher";
405   - studentBean = userDao.getTeacherWithCard(cardNum,schoolId);
406   - photo=studentBean.getFace();
  282 + public Result sendFailFace(SendFaceBean faceBean) {
  283 + List<SendRecordBean> recordList = baseService.getSendRecordList(faceBean);
  284 + if(CollectionUtils.isEmpty(recordList)) return ResultGenerator.genSuccessResult();
  285 + recordList.stream().forEach(s->{
  286 + try{
  287 + //用户类型1老师2学生
  288 + Integer userType = s.getUserType();
  289 + String userId = s.getUserId();
  290 + Integer schoolId = s.getSchoolId();
  291 + String deviceId = s.getDeviceID();
  292 + //2.重新下发
  293 + StudentBean bean = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  294 + userDao.getStudentByUserId(userId,null) : userDao.getTeacherByUserId(userId,null);
  295 + String cardNum = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  296 + bean.getStudent_num() : bean.getTeacher_num();
  297 + String photo = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  298 + bean.getPhoto() : bean.getFace();
  299 + String studentCode = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  300 + bean.getStudentCode() : bean.getNum();
  301 + if(Objects.isNull(bean) || StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)) return;
  302 +
  303 + String userName= bean.getName();
  304 + String filePath = baseService.checkUserFace(bean,userType,schoolId);
  305 + File file = new File(filePath);//图片
  306 + if(file.exists()) return;
  307 + Integer clintType = userDao.getClintTypeByDeviceId(deviceId);
  308 + //下发海康人脸
  309 + if(clintType.intValue()== 18 || clintType.intValue()== 28){
  310 + //1.先删除人脸
  311 + if (cmsServer.getIsDeviceOnline(deviceId)) {
  312 + String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + "";
  313 + cmsServer.deleteFace(deviceId, cardNo,schoolId);
407 314 }else{
408   - typeName= "Student";
409   - studentBean= userDao.getStudentWithCard(cardNum,schoolId);
410   - photo=studentBean.getPhoto();
411   - }
412   - if(studentBean==null|| StringUtils.isBlank(photo)){
413   - continue;
414   - }
415   - String userName= studentBean.getName();
416   - String studentCode = studentBean.getStudentCode();
417   - String filePath="";
418   - //下发海康人脸
419   - if(clintType.intValue()== 18 || clintType.intValue()== 28){
420   - //1.先删除人脸
421   - if (cmsServer.getIsDeviceOnline(deviceId)) {
422   - String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + "";
423   - cmsServer.deleteFace(deviceId, cardNo,schoolId);
424   - }else{
425   - //不在线,去253服务器上删除
426   - HttpUtil.deleteCard(deviceId, cardNum);
427   - }
428   - //以学籍号为名的文件名
429   - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
430   - //100服务器人脸照绝对路径
431   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
432   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
433   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
434   - if(photo.indexOf("f0i5l7e5")!=-1){
435   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
436   - filePath= path_3 + afterStr;
437   - }
438   - if(photo.indexOf("face17e5")!=-1){
439   - filePath = path_2 + "\\" + fileName;
440   - }
441   - if(photo.indexOf("face17e50")!=-1){
442   - filePath = path_1 + "\\" + fileName;
443   - }
444   - if(filePath.indexOf("?v=")!=-1){
445   - filePath = filePath.split("\\?")[0];
446   - }
447   - File file = new File(filePath);//图片
448   - if(file.exists()){
449   - String targetPath = FileUtils.picPathComp + file.getName();
450   - try {
451   - CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
452   - } catch (Exception e) {
453   - log.error("压缩图片失败:",e);
454   - continue;
455   - }
456   - if(!StringUtils.isBlank(cardNum)) {
457   - baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId);
458   - }
459   - }
  315 + //不在线,去253服务器上删除
  316 + HttpUtil.deleteCard(deviceId, cardNum);
460 317 }
461   - //下发大华人脸
462   - if(clintType.intValue()== 22 || clintType.intValue()== 29){
463   - HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId);
464   - }
465   - }catch (Exception e){
466   - log.error("下发失败表人脸失败,异常信息:{}",e);
467   - continue;
  318 + String targetPath = FileUtils.picPathComp + file.getName();
  319 + CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
  320 + baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId);
468 321 }
469   - }
470   - }
471   - return ResultGenerator.genSuccessResult();
472   - }
473   -
474   -
475   - @Override
476   - public Result sendFailFace2(Integer schoolId,String deviceIds) {
477   - if(schoolId ==null){
478   - return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空");
479   - }
480   - List<SendRecordBean> resultList = new ArrayList<>();
481   - if(StringUtils.isNotBlank(deviceIds)){
482   - //设备集合
483   - String[] deviceArr = deviceIds.split(",");
484   - List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr));
485   - for(String deviceId : deviceList){
486   - List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord2(schoolId,deviceId);
487   - resultList.addAll(recordBeanList);
488   - }
489   - }else{
490   - List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId);
491   - resultList.addAll(recordBeanList);
492   - }
493   - if(resultList.size()>0){
494   - for(SendRecordBean recordBean : resultList){
495   - try{
496   - //用户类型1老师2学生
497   - int userType = recordBean.getUserType();
498   - //人脸卡号
499   - String cardNum = recordBean.getNum();
500   - //设备ID、设备类型
501   - String deviceId = recordBean.getDeviceID();
502   - Integer clintType = userDao.getClintTypeByDeviceId(deviceId);
503   - //2.重新下发
504   - StudentBean studentBean= null;
505   - String typeName ="";
506   - String photo = "";
507   - if(userType ==1){
508   - typeName= "Teacher";
509   - studentBean = userDao.getTeacherWithCard(cardNum,schoolId);
510   - photo=studentBean.getFace();
511   - }else{
512   - typeName= "Student";
513   - studentBean= userDao.getStudentWithCard(cardNum,schoolId);
514   - photo=studentBean.getPhoto();
515   - }
516   - if(studentBean==null|| StringUtils.isBlank(photo)){
517   - continue;
518   - }
519   - String userName= studentBean.getName();
520   - String studentCode = studentBean.getStudentCode();
521   - String filePath="";
522   - //下发海康人脸
523   - if(clintType.intValue()== 18 || clintType.intValue()== 28){
524   - //1.先删除人脸
525   - if (cmsServer.getIsDeviceOnline(deviceId)) {
526   - String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + "";
527   - cmsServer.deleteFace(deviceId, cardNo,schoolId);
528   - }else{
529   - //不在线,去253服务器上删除
530   - HttpUtil.deleteCard(deviceId, cardNum);
531   - }
532   - //以学籍号为名的文件名
533   - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
534   - //100服务器人脸照绝对路径
535   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
536   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
537   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
538   - if(photo.indexOf("f0i5l7e5")!=-1){
539   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
540   - filePath= path_3 + afterStr;
541   - }
542   - if(photo.indexOf("face17e5")!=-1){
543   - filePath = path_2 + "\\" + fileName;
544   - }
545   - if(photo.indexOf("face17e50")!=-1){
546   - filePath = path_1 + "\\" + fileName;
547   - }
548   - if(filePath.indexOf("?v=")!=-1){
549   - filePath = filePath.split("\\?")[0];
550   - }
551   - File file = new File(filePath);//图片
552   - if(file.exists()){
553   - String targetPath = FileUtils.picPathComp + file.getName();
554   - try {
555   - CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
556   - } catch (Exception e) {
557   - log.error("压缩图片失败:",e);
558   - continue;
559   - }
560   - if(!StringUtils.isBlank(cardNum)) {
561   - baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId);
562   - }
563   - }
564   - }
565   - //下发大华人脸
566   - if(clintType.intValue()== 22 || clintType.intValue()== 29){
567   - HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId);
568   - }
569   - }catch (Exception e){
570   - log.error("下发失败表人脸失败,异常信息:{}",e);
571   - continue;
  322 + if(clintType.intValue()== 22 || clintType.intValue()== 29){
  323 + HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId);
572 324 }
  325 + }catch (Exception e){
  326 + log.error("下发失败表人脸失败,异常信息:{}",e);
  327 + return;
573 328 }
574   - }
  329 + });
575 330 return ResultGenerator.genSuccessResult();
576 331 }
577 332  
578 333 @Override
579   - public Result deleteFace(Integer schoolId,String cards,String deviceIds) {
580   - if(StringUtils.isBlank(cards)){
581   - return ResultGenerator.genFailResult("删除人脸卡号为空");
582   - }
583   - List<String> deviceList = new ArrayList<>();
584   - if(StringUtils.isBlank(deviceIds)){
585   - List<String> clintList = userDao.getDeviceIds(schoolId,null);
586   - if(CollectionUtils.isNotEmpty(clintList)){
587   - deviceList.addAll(clintList);
588   - }
589   - }else{
590   - //设备集合
591   - String[] deviceArr = deviceIds.split(",");
592   - deviceList= new ArrayList<>(Arrays.asList(deviceArr));
593   - }
594   - String[] cardArr = cards.split(",");
595   - List<String> cardList = new ArrayList<>(Arrays.asList(cardArr));
  334 + public Result deleteFace(SendFaceBean faceBean) {
  335 + //下发设备集合
  336 + List<String> deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId());
  337 + List<String> cardList = faceBean.getCardList();
  338 + if(CollectionUtils.isEmpty(cardList)) return ResultGenerator.genFailResult("删除卡号必传");
596 339 for(String card : cardList){
597   - //未指定设备,删除学校下所有
598   - if(CollectionUtils.isNotEmpty(deviceList)) {
599   - for (String sno : deviceList) {
600   - try {
601   - //设备类型
602   - Integer clintType = userDao.getClintTypeByDeviceId(sno);
603   - if (clintType.intValue() == 18 || clintType.intValue() == 28) {
604   - //删除海康设备人脸
605   - if (cmsServer.getIsDeviceOnline(sno)) {
606   - String cardNo = Long.parseLong(baseService.getCard(card), 16) + "";
607   - cmsServer.deleteFace(sno, cardNo, schoolId);
608   - } else {
609   - HttpUtil.deleteCard(sno, card);
610   - }
611   - }
612   - if (clintType.intValue() == 22 || clintType.intValue() == 29) {
613   - //删除大华设备人脸
614   - HttpUtil.deleteDHFace(schoolId, card, sno);
  340 + for (String sno : deviceList) {
  341 + try {
  342 + //设备类型
  343 + Integer clintType = userDao.getClintTypeByDeviceId(sno);
  344 + if (clintType.intValue() == 18 || clintType.intValue() == 28) {
  345 + //删除海康设备人脸
  346 + if (cmsServer.getIsDeviceOnline(sno)) {
  347 + String cardNo = Long.parseLong(baseService.getCard(card), 16) + "";
  348 + cmsServer.deleteFace(sno, cardNo, faceBean.getSchoolId());
  349 + } else {
  350 + HttpUtil.deleteCard(sno, card);
615 351 }
616   - //删除成功记录
617   - sendRecordDao.deleteUserFaceSuccess(schoolId,card,sno);
618   - sendRecordDao.deleteRecord(schoolId,sno,card);
619   - } catch (Exception e) {
620   - log.error("删除人脸失败,异常信息:{}", e);
621   - continue;
622 352 }
  353 + if (clintType.intValue() == 22 || clintType.intValue() == 29) {
  354 + //删除大华设备人脸
  355 + HttpUtil.deleteDHFace(faceBean.getSchoolId(), card, sno);
  356 + }
  357 + //删除成功记录
  358 + sendRecordDao.deleteRecord(faceBean.getSchoolId(), sno,card);
  359 + } catch (Exception e) {
  360 + log.error("删除人脸失败,异常信息:{}", e);
  361 + continue;
623 362 }
624 363 }
625 364 }
626 365 return ResultGenerator.genSuccessResult();
627 366 }
628 367  
629   - @Override
630   - public Result sendFaceForNoSend(Integer schoolId,Integer studentType,String sex,Integer userType,String deviceIds,Integer groupId) {
631   - //若未传下发,则下发该学校下所有设备
632   - //下发设备集合
633   - List<String> idLists = null;
634   - if(StringUtils.isBlank(deviceIds)){
635   - idLists = userDao.getDeviceIds(schoolId,null);
636   - }else{
637   - String[] deviceArr = deviceIds.split(",");
638   - idLists= new ArrayList<>(Arrays.asList(deviceArr));
639   - }
640   - if(CollectionUtils.isEmpty(idLists)){
641   - log.warn("该学校下未查询到下发设备");
642   - return ResultGenerator.genFailResult("该学校下未查询到下发设备");
643   - }
644   - //下发用户集合
645   - List<StudentBean> list = null;
646   - if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId ==null) {
647   - list = baseService.getStudentList(schoolId,studentType,sex);
648   - }else if(userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId !=null){
649   - list = baseService.getStudentListByGroup(schoolId,studentType,sex,groupId);
650   - }
651   - if(userType.intValue()==EnumSzBusinessType.EnumUserType.TEACHER.code){
652   - list = baseService.getTeacherList(schoolId);
653   - }
654   - //异步执行下发
655   - sendFaceForNoSend(schoolId,userType,list,idLists);
656   - int fileSize = list.size();
657   - int clintNum = idLists.size();
658   - //下发所用时长
659   - int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
660   - //下发截止时间
661   - String dateStr = baseService.getTime(fileSize,clintNum,timeLength);
662   - Map map = new HashMap();
663   - map.put("timeLength",timeLength);
664   - map.put("afterDate",dateStr);
665   - map.put("fileSize",fileSize);
666   - return ResultGenerator.genSuccessResult(objectMapper.toJson(map));
667   - }
668   -
  368 + /**
  369 + * 下发未发人脸
  370 + * @param studentList
  371 + * @param deviceIds
  372 + */
669 373 @Async
670   - public void sendFaceForNoSend(Integer schoolId,Integer userType,List<StudentBean> studentList,List<String> deviceIds){
671   - log.info("统计共有:"+studentList.size()+"张卡,"+deviceIds.size()+"台设备." );
672   - for(StudentBean studentBean : studentList){
  374 + public void sendFaceForNoSend(SendFaceBean faceBean,List<StudentBean> studentList,List<String> deviceIds){
  375 + log.info("统计学校共有:"+studentList.size()+"张卡,"+deviceIds.size()+"台设备." );
  376 + List<SendRecordBean> sendRecords = baseService.getSendRecordList(faceBean);
  377 + List<SendRecordBean> list = sendRecords.parallelStream()
  378 + .collect(Collectors.toMap(t-> Arrays.asList(t.getSchoolId(),t.getNum(),t.getDeviceID()),
  379 + Function.identity(),(oldValue, newValue) -> oldValue))
  380 + .values().stream().collect(Collectors.toList());
  381 + studentList.stream().forEach(s->{
  382 + String userName = s.getName();
  383 + String studentCode = s.getStudentCode();
  384 + String studentNum = s.getStudent_num();
  385 + String filePath = baseService.checkUserFace(s, faceBean.getUserType(), faceBean.getSchoolId());
  386 + if(StringUtils.isBlank(filePath)) return;
  387 + File file = new File(filePath);
  388 + if(!file.exists()) return;
  389 + String targetPath = FileUtils.picPathComp + file.getName();
  390 + try {
  391 + CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
  392 + } catch (Exception e) {
  393 + log.error("压缩图片失败:",e);
  394 + return;
  395 + }
673 396 for(String sno : deviceIds){
674 397 try{
675   - //卡号
676   - String cardNum = userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num();
677   - //人脸照
678   - String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
679   - if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){
680   - continue;
681   - }
682   - String userName= studentBean.getName();
683   - String userId = studentBean.getUser_id();
684   - String studentCode = studentBean.getStudentCode();
685   - List<SendRecordBean> bean = sendRecordDao.getRecordIsExit(sno,cardNum,userId);
686   - if(CollectionUtils.isNotEmpty(bean)){
687   - continue;
688   - }
689   - String typeName= userType.intValue()==1?"Teacher":"Student";
690   - //以学籍号为名的文件名
691   - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
692   - //100服务器人脸照绝对路径
693   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
694   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
695   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
696   - String filePath="";
697   - if(photo.indexOf("f0i5l7e5")!=-1){
698   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\");
699   - filePath= path_3 + afterStr;
700   - }
701   - if(photo.indexOf("face17e5")!=-1){
702   - filePath = path_2 + "\\" + fileName;
703   - }
704   - if(photo.indexOf("face17e50")!=-1){
705   - filePath = path_1 + "\\" + fileName;
706   - }
707   - if(filePath.indexOf("?v=")!=-1){
708   - filePath = filePath.split("\\?")[0];
709   - }
710   - File file = new File(filePath);//图片
711   - if(file.exists()){
712   - String targetPath = FileUtils.picPathComp + file.getName();
713   - try {
714   - CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
715   - } catch (Exception e) {
716   - log.error("压缩图片失败:",e);
717   - continue;
718   - }
719   - if(!StringUtils.isBlank(cardNum)) {
720   - //设备类型
721   - Integer clintType = userDao.getClintTypeByDeviceId(sno);
722   - if(clintType.intValue()== 18 || clintType.intValue()== 28){
723   - baseService.sendImg(file.getAbsolutePath(), targetPath, sno, cardNum, userName, String.valueOf(userType), schoolId);
724   - }
725   - //下大华人脸
726   - if(clintType.intValue()== 22 || clintType.intValue()== 29){
727   - //下发单个人脸至大华设备
728   - HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,sno);
729   - }
730   - }
731   - }
  398 + if(baseService.checkSendRecord(list,sno, faceBean.getSchoolId(), studentNum)) continue;
  399 + Integer clintType = userDao.getClintTypeByDeviceId(sno);
  400 + //大华
  401 + if(clintType.intValue()== 18 || clintType.intValue()== 28)
  402 + baseService.sendImg(file.getAbsolutePath(), targetPath, sno, studentNum, userName,
  403 + String.valueOf(faceBean.getUserType()), faceBean.getSchoolId());
  404 + //海康
  405 + if(clintType.intValue()== 22 || clintType.intValue()== 29)
  406 + HttpUtil.uploadDHImgForOne(filePath, faceBean.getSchoolId(), studentCode,clintType,sno);
732 407 }catch (Exception e){
733 408 log.error("人脸下发失败");
734 409 e.printStackTrace();
735 410 continue;
736 411 }
737 412 }
738   - }
  413 + });
739 414 }
740 415  
741 416 @Override
742 417 public Result againNoSendOneFace(MultipartFile file, Integer schoolId, String cardNum, Integer userType, String deviceIds) {
743   - if(StringUtils.isBlank(cardNum)){
744   - return ResultGenerator.genFailResult("卡号为空");
745   - }
746   - if(StringUtils.isBlank(deviceIds)){
747   - return ResultGenerator.genFailResult("未指定下发设备");
748   - }
749   - StudentBean studentBean=null;
750   - if(userType.intValue()==2){
751   - studentBean= userDao.getStudentWithCard(cardNum,schoolId);
752   - }else{
753   - studentBean= userDao.getTeacherWithCard(cardNum,schoolId);
754   - }
755   - if(studentBean ==null){
756   - return ResultGenerator.genFailResult("此卡号未查询到对应学生/老师信息");
757   - }
  418 + if(StringUtils.isBlank(cardNum)) return ResultGenerator.genFailResult("卡号为空");
  419 + if(StringUtils.isBlank(deviceIds)) return ResultGenerator.genFailResult("未指定下发设备");
  420 + StudentBean studentBean = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  421 + userDao.getStudentWithCard(cardNum,schoolId) : userDao.getTeacherWithCard(cardNum,schoolId);
  422 + if(Objects.isNull(studentBean)) return ResultGenerator.genFailResult("此卡号未查询到对应学生/老师信息");
  423 +
758 424 String userName = studentBean.getName();
759   - String studentCode = userType.intValue()==1?studentBean.getNum():studentBean.getStudentCode();
  425 + String studentCode = userType.intValue()==1 ? studentBean.getNum(): studentBean.getStudentCode();
760 426 String typeName = userType.intValue()==1?"Teacher":"Student";
761   - //100服务器人脸照绝对路径
762   - String path = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
763   - if(!new File(path).exists()){
764   - new File(path).mkdirs();
765   - }
766 427 //以学籍号为名的文件名
767 428 String fileName = studentCode + ".png";
768   - //人脸文件路径
769   - String facePath = path + "\\" +fileName;
770   - try {
771   - File absolutePath = new File(facePath);
772   - FileOutputStream fileOutputStream = new FileOutputStream(absolutePath);
773   - fileOutputStream.write(file.getBytes());
774   - fileOutputStream.close();
775   - }catch (IOException e){
776   - log.error("文件处理异常: ",e);
777   - }
778   -// //在线活体检测
779   -// String result = HttpUtil.checkFace(facePath);
780   -// if(StringUtils.isBlank(result) || result.equals("false")){
781   -// log.error("人脸检测不合格!");
782   -// return ResultGenerator.genFailResult("请添加规范的人脸照片.");
783   -// }
  429 + String facePath = "";
  430 + if(file.isEmpty()) facePath = this.getFilePath(schoolId,typeName,fileName,file);
  431 + else facePath = baseService.checkUserFace(studentBean,userType,schoolId);
784 432 String targetPath = FileUtils.picPathComp + file.getName();
785 433 try {
786 434 CompressPic.CompressPic(new File(facePath).getAbsolutePath(), targetPath);
787 435 } catch (Exception e) {
788 436 log.error("压缩图片失败: ",e);
789 437 }
790   - String[] deviceArr = deviceIds.split(",");
791   - List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr));
  438 + List<String> deviceList= Arrays.asList(deviceIds.split(","));
792 439 if(CollectionUtils.isNotEmpty(deviceList)){
793 440 for(String deviceId : deviceList) {
794 441 //获取设备类型
... ... @@ -808,6 +455,24 @@ public class UserOperateServiceImpl implements UserOperateService {
808 455 return ResultGenerator.genSuccessResult();
809 456 }
810 457  
  458 + private String getFilePath(Integer schoolId,String typeName,String fileName,MultipartFile file){
  459 + //100服务器人脸照绝对路径
  460 + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
  461 + File saveFile = new File(path);
  462 + if(!saveFile.exists()) saveFile.mkdirs();
  463 + //人脸文件路径
  464 + String facePath = path + "\\" + fileName;
  465 + try {
  466 + File absolutePath = new File(facePath);
  467 + FileOutputStream fileOutputStream = new FileOutputStream(absolutePath);
  468 + fileOutputStream.write(file.getBytes());
  469 + fileOutputStream.close();
  470 + }catch (IOException e){
  471 + log.error("文件处理异常: ",e);
  472 + }
  473 + return facePath;
  474 + }
  475 +
811 476 @Override
812 477 public Result insertUpdateCard(String cardNums) {
813 478 String[] cardArr = cardNums.split(",");
... ... @@ -843,78 +508,6 @@ public class UserOperateServiceImpl implements UserOperateService {
843 508 return new Result();
844 509 }
845 510  
846   - @Override
847   - public Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath) {
848   - File imgPathFile = new File(faceSrcPath);//目录
849   - File[] imgfiles = imgPathFile.listFiles();
850   - if(imgfiles.length==0){
851   - return ResultGenerator.genFailResult("未获取要下发的人脸照片。");
852   - }
853   - List<StudentBean> sendFaces = new ArrayList<>();
854   - for (int i = 0; i < imgfiles.length; i++) {
855   - try{
856   - //人脸照片
857   - File file = imgfiles[i];
858   - if(!file.isFile()){
859   - continue;
860   - }
861   - if (file.exists()){
862   - //原始文件路径
863   - String srcPath = file.getAbsolutePath();
864   - //原始文件名
865   - String fileName = file.getName();
866   - System.out.println("文件名:"+ fileName+", 学籍号:"+ fileName.split("\\.")[0]);
867   - StudentBean studentBean = new StudentBean();
868   - if (userType.intValue()==1) {
869   - studentBean = userDao.getTeacherWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId));
870   - }else {
871   - studentBean = userDao.getStudentWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId));
872   - }
873   - if(studentBean == null){
874   - continue;
875   - }
876   - String typeName = userType.intValue() ==1 ? "Teacher" : "Student";
877   - String targetPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
878   -// //目标路径
879   - targetPath = targetPath + "\\" + fileName;
880   - //复制文件
881   - copy(srcPath,targetPath);
882   - String savePath = "http://campus.myjxt.com//face17e50/School"+ schoolId + "/" + typeName + "/" + fileName;
883   - if(userType.intValue() ==1){
884   - studentBean.setFace(savePath);
885   - }else {
886   - studentBean.setPhoto(savePath);
887   - }
888   - //savePath
889   - userDao.updateUser(studentBean.getUser_id(),savePath);
890   - sendFaces.add(studentBean);
891   - }
892   - file.delete();
893   - }catch (Exception e){
894   - e.printStackTrace();
895   - continue;
896   - }
897   - }
898   - if(StringUtils.isBlank(deviceIds)){
899   - return ResultGenerator.genFailResult("未选择下发设备");
900   - }
901   - String[] deviceArr = deviceIds.split(",");
902   - List<String> deviceList = new ArrayList<>(Arrays.asList(deviceArr));
903   - //异步执行下发
904   - asyncSendFace(sendFaces,deviceList,schoolId,userType);
905   - int fileSize = sendFaces.size();
906   - int clintNum = deviceList.size();
907   - //下发所用时长
908   - int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
909   - //下发截止时间
910   - String dateStr = baseService.getTime(fileSize,clintNum,timeLength);
911   - Map map = new HashMap();
912   - map.put("timeLength",timeLength);
913   - map.put("afterDate",dateStr);
914   - map.put("fileSize",fileSize);
915   - return ResultGenerator.genSuccessResult(objectMapper.toJson(map));
916   - }
917   -
918 511 public void asyncSendFace(List<StudentBean> sendFaces,List<String> deviceList,Integer schoolId,Integer userType){
919 512 log.info("总共检测到:{},张人脸照片。",sendFaces.size());
920 513 //设备类型
... ... @@ -925,103 +518,18 @@ public class UserOperateServiceImpl implements UserOperateService {
925 518 }
926 519 }
927 520  
928   - private static void copy(String srcPathStr, String desPathStr) {
929   - //获取源文件的名称
930   - try {
931   - FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象
932   - FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象
933   - byte datas[] = new byte[1024*8];//创建搬运工具
934   - int len = 0;//创建长度
935   - while((len = fis.read(datas))!=-1)//循环读取数据
936   - {
937   - fos.write(datas,0,len);
938   - }
939   - fis.close();//释放资源
940   - fis.close();//释放资源
941   - }
942   - catch (Exception e)
943   - {
944   - e.printStackTrace();
945   - }
946   - }
947 521  
948   - @Override
949   - public Result sendFaceByClassId(Integer schoolId,String classIds,String deviceIds,Integer studentType,String sex,Integer isCheck) {
950   - //下发设备集合
951   - List<String> deviceList = null;
952   - if(StringUtils.isBlank(deviceIds)){
953   - deviceList = deviceDao.selectDeviceBySchoolId(schoolId);
954   - }else{
955   - deviceList= new ArrayList<>(Arrays.asList(deviceIds.split(",")));
956   - }
957   - List<StudentBean> resultCard = new ArrayList<>();
958   - List<String> resultDevices = new ArrayList<>();
959   - //根据类型获取下发用户信息
960   - List<StudentBean> studentBeanList = baseService.getStudentByClassId(schoolId,classIds,studentType,sex);
961   - log.info("统计共有下发用户数量:{}",studentBeanList.size());
962   - if(isCheck !=null){
963   - for(StudentBean studentBean : studentBeanList){
964   - String cardNum = studentBean.getStudent_num();
965   - boolean isOk = true;
966   - for(String deviceId : deviceList){
967   - if (cmsServer.getIsDeviceOnline(deviceId)) {
968   - String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + "";
969   - isOk = cmsServer.getFace(deviceId,cardNo,null);
970   - }else{
971   - isOk = HttpUtil.getCard(deviceId, cardNum);
972   - }
973   - if(!isOk){
974   - resultCard.add(studentBean);
975   - resultCard.add(studentBean);
976   - resultDevices.add(deviceId);
977   - }
978   - }
979   - }
980   - //去重重复数据
981   - studentBeanList = resultCard.stream().collect(Collectors.collectingAndThen(
982   - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
983   - //去重重复数据
984   - deviceList = resultDevices.stream().distinct().collect(Collectors.toList());
985   - }
986   - log.info("统计共有下发用户数量:{}",studentBeanList.size());
987   - //设备类型
988   - Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0));
989   - if(clintType.intValue()== 22 || clintType.intValue()== 29){
990   - //发送大华设备
991   - HttpUtil.uploadDHImgByClassId(String.valueOf(schoolId),deviceIds,classIds);
992   - }
993   - if(clintType.intValue()== 18 || clintType.intValue()== 28){
994   - //发送海康设备:异步执行
995   - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList);
996   - }
997   - int fileSize = studentBeanList.size();
998   - int clintNum = deviceList.size();
999   - //下发所用时长
1000   - int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
1001   - //下发截止时间
1002   - String dateStr = baseService.getTime(fileSize,clintNum,timeLength);
1003   - Map map = new HashMap();
1004   - map.put("timeLength",timeLength);
1005   - map.put("afterDate",dateStr);
1006   - map.put("fileSize",fileSize);
1007   - return ResultGenerator.genSuccessResult(objectMapper.toJson(map));
1008   - }
1009 522  
1010 523 @Override
1011   - public Result sendFaceByKeyword(Integer schoolId,String keyword,String deviceIds,Integer studentType,String sex,Integer isCheck) {
  524 + public Result sendFaceByClassId(SendFaceBean faceBean) {
1012 525 //下发设备集合
1013   - List<String> deviceList = null;
1014   - if(StringUtils.isBlank(deviceIds)){
1015   - deviceList = deviceDao.selectDeviceBySchoolId(schoolId);
1016   - }else{
1017   - deviceList= Arrays.asList(deviceIds.split(","));
1018   - }
  526 + List<String> deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId());
1019 527 List<StudentBean> resultCard = new ArrayList<>();
1020 528 List<String> resultDevices = new ArrayList<>();
1021 529 //根据类型获取下发用户信息
1022   - List<StudentBean> studentBeanList = baseService.getStudentByKeyword(schoolId,keyword,studentType,sex);
  530 + List<StudentBean> studentBeanList = baseService.getStudentByClassId(faceBean);
1023 531 log.info("统计共有下发用户数量:{}",studentBeanList.size());
1024   - if(isCheck !=null){
  532 + if(Objects.equals(faceBean.getIsCheck(),1)){
1025 533 for(StudentBean studentBean : studentBeanList){
1026 534 String cardNum = studentBean.getStudent_num();
1027 535 boolean isOk = true;
... ... @@ -1041,21 +549,20 @@ public class UserOperateServiceImpl implements UserOperateService {
1041 549 }
1042 550 //去重重复数据
1043 551 studentBeanList = resultCard.stream().collect(Collectors.collectingAndThen(
1044   - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
  552 + Collectors.toCollection(() -> new TreeSet<>(Comparator
  553 + .comparing(StudentBean::getStudent_num))), ArrayList::new));
1045 554 //去重重复数据
1046 555 deviceList = resultDevices.stream().distinct().collect(Collectors.toList());
1047 556 }
1048 557 log.info("统计共有下发用户数量:{}",studentBeanList.size());
1049 558 //设备类型
1050 559 Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0));
1051   - if(clintType.intValue()== 22 || clintType.intValue()== 29){
1052   - //发送大华设备
1053   - HttpUtil.uploadDHImgByClassId(String.valueOf(schoolId),deviceIds,keyword);
1054   - }
1055   - if(clintType.intValue()== 18 || clintType.intValue()== 28){
1056   - //发送海康设备:异步执行
1057   - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList);
1058   - }
  560 + //发送大华设备
  561 + if(clintType.intValue()== 22 || clintType.intValue()== 29)
  562 + HttpUtil.uploadDHImgByClassId(String.valueOf(faceBean.getSchoolId()),faceBean.getDeviceIds(),faceBean.getClassIds());
  563 + //发送海康设备:异步执行
  564 + if(clintType.intValue()== 18 || clintType.intValue()== 28)
  565 + baseService.sendUserFaceByAsyncThread(faceBean.getSchoolId(),2,studentBeanList,deviceList);
1059 566 int fileSize = studentBeanList.size();
1060 567 int clintNum = deviceList.size();
1061 568 //下发所用时长
... ... @@ -1070,16 +577,15 @@ public class UserOperateServiceImpl implements UserOperateService {
1070 577 }
1071 578  
1072 579 @Override
1073   - public Result noSendByKeyword(Integer schoolId,String keyword,String deviceIds) {
  580 + public Result sendNuFaceByClassId(SendFaceBean faceBean) {
1074 581 //下发设备集合
1075   - List<String> deviceList = Arrays.asList(deviceIds.split(","));
  582 + List<String> deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId());
1076 583 //根据类型获取下发用户信息
1077   - List<StudentBean> studentBeanList = baseService.getStudentByKeyword(schoolId,keyword,null,null);
1078   -
  584 + List<StudentBean> studentBeans = Objects.equals(faceBean.getUserType(),EnumSzBusinessType.EnumUserType.TEACHER.code) ?
  585 + baseService.getStudentByClassId(faceBean) : baseService.getTeacherList(faceBean.getSchoolId());
1079 586 //异步执行下发
1080   - sendFaceForNoSend(schoolId,2,studentBeanList,deviceList);
1081   -
1082   - int fileSize = studentBeanList.size();
  587 + this.sendFaceForNoSend(faceBean,studentBeans,deviceList);
  588 + int fileSize = studentBeans.size();
1083 589 int clintNum = deviceList.size();
1084 590 //下发所用时长
1085 591 int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
... ... @@ -1093,17 +599,11 @@ public class UserOperateServiceImpl implements UserOperateService {
1093 599 }
1094 600  
1095 601 @Override
1096   - public Result sendFaceByRoomId(Integer schoolId,Integer roomId,String deviceIds) {
  602 + public Result sendFaceByRoomId(SendFaceBean faceBean) {
1097 603 //下发设备集合
1098   - List<String> deviceList = new ArrayList<>();
1099   - if(StringUtils.isBlank(deviceIds)){
1100   - deviceList = deviceDao.selectDeviceBySchoolId(schoolId);
1101   - }else{
1102   - String[] deviceArr = deviceIds.split(",");
1103   - deviceList= new ArrayList<>(Arrays.asList(deviceArr));
1104   - }
  604 + List<String> deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId());
1105 605 //根据类型获取下发用户信息
1106   - List<StudentBean> studentBeanList = baseService.getStudentListByRoomId(schoolId,roomId);
  606 + List<StudentBean> studentBeanList = baseService.getStudentListByRoomId(faceBean.getSchoolId(),faceBean.getRoomId());
1107 607 log.info("统计共有下发用户数量:{}",studentBeanList.size());
1108 608 //设备类型
1109 609 Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0));
... ... @@ -1113,7 +613,7 @@ public class UserOperateServiceImpl implements UserOperateService {
1113 613 // }
1114 614 if(clintType.intValue()== 18 || clintType.intValue()== 28){
1115 615 //发送海康设备:异步执行
1116   - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList);
  616 + baseService.sendUserFaceByAsyncThread(faceBean.getSchoolId(),faceBean.getUserType(),studentBeanList,deviceList);
1117 617 }
1118 618 int fileSize = studentBeanList.size();
1119 619 int clintNum = deviceList.size();
... ... @@ -1129,148 +629,82 @@ public class UserOperateServiceImpl implements UserOperateService {
1129 629 }
1130 630  
1131 631 @Override
1132   - public Result deleteFaceBySchoolId(Integer schoolId, String deviceIds) {
  632 + public Result deleteByCondition(SendFaceBean faceBean) {
1133 633 //下发设备集合
1134   - List<String> deviceList = null;
1135   - if(StringUtils.isBlank(deviceIds)){
1136   - deviceList = deviceDao.selectDeviceBySchoolId(schoolId);
1137   - }else{
1138   - String[] deviceArr = deviceIds.split(",");
1139   - deviceList= new ArrayList<>(Arrays.asList(deviceArr));
1140   - }
1141   - List<SendRecordBean> students= baseService.getRecordCardBySchoolId(schoolId.intValue());
1142   - if(!CollectionUtils.isEmpty(students)){
1143   - for(SendRecordBean s : students){
1144   - String cardNum = s.getNum();
1145   - StudentBean studentBean = userDao.getStudentWithCard(cardNum,schoolId.intValue());
1146   - StudentBean teacher = userDao.getTeacherWithCard(cardNum,schoolId.intValue());
1147   - if(studentBean == null && teacher ==null){
1148   - deviceList.stream().forEach(c->{
1149   - boolean isOk = false;
1150   - if (cmsServer.getIsDeviceOnline(c)) {
1151   - String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + "";
1152   - isOk = cmsServer.deleteFace(c,cardNo,null);
1153   - }else{
1154   - isOk = HttpUtil.deleteCard(c, cardNum);
1155   - }
1156   - if(isOk){
1157   - //删除成功记录
1158   - sendRecordDao.deleteUserFaceSuccess(schoolId,cardNum,c);
1159   - sendRecordDao.deleteRecord(schoolId,c,cardNum);
1160   - }
1161   - });
1162   - }
  634 + List<String> deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId());
  635 + //根据类型获取下发用户信息
  636 + List<StudentBean> studentBeans = Objects.equals(faceBean.getUserType(),EnumSzBusinessType.EnumUserType.STUDENT.code) ?
  637 + baseService.getStudentByClassId(faceBean) : baseService.getTeacherList(faceBean.getSchoolId());
  638 + List<SendRecordBean> students = baseService.getSendRecordList(faceBean);
  639 + if(CollectionUtils.isEmpty(students)) return ResultGenerator.genSuccessResult();
  640 + for(SendRecordBean s : students){
  641 + String cardNum = s.getNum();
  642 + StudentBean bean = studentBeans.stream().filter(f->Objects.equals(f.getNum(),cardNum) &&
  643 + Objects.equals(f.getSchoolId(),faceBean.getSchoolId())).findFirst().orElse(null);
  644 + if(Objects.isNull(bean)){
  645 + deviceList.stream().forEach(c->{
  646 + boolean isOk = false;
  647 + if (cmsServer.getIsDeviceOnline(c)) {
  648 + String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + "";
  649 + isOk = cmsServer.deleteFace(c,cardNo,null);
  650 + }else{
  651 + isOk = HttpUtil.deleteCard(c, cardNum);
  652 + }
  653 + if(isOk) sendRecordDao.deleteRecord(faceBean.getSchoolId(),c,cardNum);
  654 + });
1163 655 }
1164 656 }
1165 657 return ResultGenerator.genSuccessResult();
1166 658 }
1167 659  
1168 660 @Override
1169   - public void checkFaceSend() {
1170   - List<SaveStudentBak> saveStudentBaks = userDao.selectStudentList();
1171   - if(!CollectionUtils.isEmpty(saveStudentBaks)) {
1172   - saveStudentBaks.stream().forEach(saveStudentBak -> {
1173   - try{
1174   - String cardNum = saveStudentBak.getCardNum();
1175   - Integer schoolId = saveStudentBak.getSchoolId();
1176   - String deviceId = saveStudentBak.getClientId();
1177   - StudentBean studentBean = userDao.getStudentWithCard(cardNum, schoolId);
1178   - if (studentBean == null) {
1179   - return;
1180   - }
1181   - String photo = studentBean.getPhoto();
1182   - if (StringUtils.isBlank(photo)) {
1183   - return;
1184   - }
1185   - int userType = studentBean.getUserType();
1186   - String userName = studentBean.getName();
1187   - String studentCode = studentBean.getStudentCode();
1188   - String typeName = "Student";
1189   - //以学籍号为名的文件名
1190   - String fileName = photo.substring(photo.lastIndexOf("/") + 1, photo.length());
1191   - //100服务器人脸照绝对路径
1192   - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
1193   - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
1194   - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\";
1195   - String filePath = "";
1196   - if (photo.indexOf("f0i5l7e5") != -1) {
1197   - String afterStr = photo.split("f0i5l7e5/")[1].replace("/", "\\");
1198   - filePath = path_3 + afterStr;
1199   - }
1200   - if (photo.indexOf("face17e5") != -1) {
1201   - filePath = path_2 + "\\" + fileName;
1202   - }
1203   - if (photo.indexOf("face17e50") != -1) {
1204   - filePath = path_1 + "\\" + fileName;
1205   - }
1206   - if (filePath.indexOf("?v=") != -1) {
1207   - filePath = filePath.split("\\?")[0];
1208   - }
1209   - //校验100服务文件存储地址上是否存在此人脸
1210   - File file = new File(filePath.trim());//图片
1211   - if (!file.exists()) {
1212   - log.error("文件不存在:" + filePath);
1213   - baseService.sendFailRecord(cardNum, filePath, deviceId, "文件不存在", String.valueOf(userType), schoolId);
1214   - return;
1215   - }
1216   - String targetPath = FileUtils.picPathComp + file.getName();
1217   - if (file.exists()) {
1218   - try {
1219   - CompressPic.CompressPic(file.getAbsolutePath(), targetPath);
1220   - } catch (Exception e) {
1221   - log.error("压缩图片失败:", e);
1222   - }
1223   - }
1224   - //设备类型
1225   - Integer clintType = userDao.getClintTypeByDeviceId(deviceId);
1226   - if (clintType.intValue() == 18 || clintType.intValue() == 28) {
1227   -// //1.先删除人脸
1228   -// if (cmsServer.getIsDeviceOnline(deviceId)) {
1229   -// String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + "";
1230   -// cmsServer.deleteFace(deviceId, cardNo, schoolId);
1231   -// } else {
1232   -// //不在线,去253服务器上删除
1233   -// HttpUtil.deleteCard(deviceId, cardNum);
1234   -// }
1235   - //2.重新下发
1236   - boolean isOk = baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId);
1237   - if (isOk) {
1238   - userDao.updateStudent(saveStudentBak.getId());
1239   - return;
1240   - } else {
1241   - }
1242   - }
1243   - //下大华人脸
1244   - if (clintType.intValue() == 22 || clintType.intValue() == 29) {
1245   - //下发单个人脸至大华设备
1246   - HttpUtil.uploadDHImgForOne(filePath, schoolId, studentCode, clintType, deviceId);
1247   - return;
1248   - }
1249   - }catch (Exception e){
1250   - log.error("下发出错");
1251   - return;
  661 + public Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath) {
  662 + File imgPathFile = new File(faceSrcPath);//目录
  663 + File[] imgfiles = imgPathFile.listFiles();
  664 + if(imgfiles.length==0) return ResultGenerator.genFailResult("未获取要下发的人脸照片。");
  665 + List<StudentBean> sendFaces = new ArrayList<>();
  666 + for (int i = 0; i < imgfiles.length; i++) {
  667 + try{
  668 + //人脸照片
  669 + File file = imgfiles[i];
  670 + if(!file.isFile())continue;
  671 + if(!file.exists()) continue;
  672 + //原始文件路径
  673 + String srcPath = file.getAbsolutePath();
  674 + //原始文件名
  675 + String fileName = file.getName();
  676 + System.out.println("文件名:"+ fileName+", 学籍号:"+ fileName.split("\\.")[0]);
  677 + StudentBean studentBean = null;
  678 + if (userType.intValue()==1) {
  679 + studentBean = userDao.getTeacherWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId));
  680 + }else {
  681 + studentBean = userDao.getStudentWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId));
1252 682 }
1253   - });
1254   - }
1255   - }
1256   -
1257   - @Override
1258   - public Result replaceFaceByKeyword(Integer schoolId,String deviceIds,String keyword) {
1259   - //下发设备集合
1260   - List<String> deviceList = null;
1261   - if(StringUtils.isBlank(deviceIds)){
1262   - deviceList = deviceDao.selectDeviceBySchoolId(schoolId);
1263   - }else{
1264   - deviceList= Arrays.asList(deviceIds.split(","));
  683 + if(Objects.isNull(studentBean)) continue;
  684 + String typeName = userType.intValue() ==1 ? "Teacher" : "Student";
  685 + String targetPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
  686 + //目标路径
  687 + targetPath = targetPath + "\\" + fileName;
  688 + //复制文件
  689 + baseService.copy(srcPath,targetPath);
  690 + String savePath = "http://campus.myjxt.com//face17e50/School"+ schoolId + "/" + typeName + "/" + fileName;
  691 + if(userType.intValue() ==1) studentBean.setFace(savePath);
  692 + else studentBean.setPhoto(savePath);
  693 + //savePath
  694 + userDao.updateUser(studentBean.getUser_id(),savePath);
  695 + sendFaces.add(studentBean);
  696 + file.delete();
  697 + }catch (Exception e){
  698 + e.printStackTrace();
  699 + continue;
  700 + }
1265 701 }
1266   - //根据类型获取下发用户信息
1267   - List<StudentBean> studentBeanList = baseService.getReplaceByKeyword(schoolId,keyword);
1268   - log.info("统计共有下发用户数量:{}",studentBeanList.size());
1269   -
1270   - //发送海康设备:异步执行
1271   - this.deleteReplaceFace(schoolId,studentBeanList,deviceList);
1272   -
1273   - int fileSize = studentBeanList.size();
  702 + if(StringUtils.isBlank(deviceIds)) return ResultGenerator.genFailResult("未选择下发设备");
  703 + String[] deviceArr = deviceIds.split(",");
  704 + List<String> deviceList = new ArrayList<>(Arrays.asList(deviceArr));
  705 + //异步执行下发
  706 + asyncSendFace(sendFaces,deviceList,schoolId,userType);
  707 + int fileSize = sendFaces.size();
1274 708 int clintNum = deviceList.size();
1275 709 //下发所用时长
1276 710 int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
... ... @@ -1282,26 +716,4 @@ public class UserOperateServiceImpl implements UserOperateService {
1282 716 map.put("fileSize",fileSize);
1283 717 return ResultGenerator.genSuccessResult(objectMapper.toJson(map));
1284 718 }
1285   -
1286   - @Async
1287   - public void deleteReplaceFace(Integer schoolId,List<StudentBean> studentBeanList,List<String> deviceList){
1288   - //100服务器;
1289   - studentBeanList.stream().forEach(s->{
1290   - String cardNum = s.getStudent_num();
1291   - deviceList.stream().forEach(c->{
1292   - boolean isOk = false;
1293   - if (cmsServer.getIsDeviceOnline(c)) {
1294   - String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + "";
1295   - isOk = HttpUtil.deleteCard100(c,cardNo);
1296   - }else{
1297   - isOk = HttpUtil.deleteCard(c, cardNum);
1298   - }
1299   - if(isOk){
1300   - //删除成功记录
1301   - sendRecordDao.deleteUserFaceSuccess(schoolId,cardNum,c);
1302   - sendRecordDao.deleteRecord(schoolId,c,cardNum);
1303   - }
1304   - });
1305   - });
1306   - }
1307 719 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java
... ... @@ -23,32 +23,14 @@ public interface SendRecordDao {
23 23 @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") int schoolId,
24 24 @Param("userType") int userType, @Param("deviceType") int deviceType);
25 25  
26   - @Select("select * from Face_SendSuccess where schoolId = #{schoolId} ")
27   - List<SendRecordBean> getSendFaceSuccess(@Param("schoolId") Integer schoolId);
28   -
29 26 @Select("select * from Face_SendSuccess where deviceID = #{deviceID} and schoolId = #{schoolId}")
30 27 List<SendRecordBean> getSenSuccesss(@Param("deviceID") String deviceId, @Param("schoolId") Integer schoolId);
31 28  
32   - @Select("select a.customerID from [dbo].[WG_SendFail] a inner join DBlan137.smartcampus.dbo.SZ_AttendanceDto b on a.deviceID=b.clint_id and b.isConnection=1 order by createTime desc")
33   - List<String> getWGFail();
34   -
35   - //获取成功表和失败人脸表中都存在的数据
36   - @Select("select a.deviceID,a.Num,a.Name from Face_SendFail a inner join Face_SendSuccess b on a.deviceID = b.deviceID where a.schoolId = 1030 and a.num = b.Num")
37   - List<SendRecordBean> getSuccessAndFail();
38   -
39 29 @Insert("insert into Face_Recoder values(#{deviceId},#{user_id},#{name},#{imgurl},#{inOrOut},#{time},#{cardNum},#{temp},#{schoolId})")
40 30 void addFaceRecoder(@Param("deviceId") String deviceId, @Param("user_id") String user_id, @Param("name") String name,
41 31 @Param("imgurl") String imgurl, @Param("inOrOut") int inOrOut, @Param("time") String time,
42 32 @Param("cardNum") String cardNum, @Param("temp") String currTemperature,@Param("schoolId") int schoolId);
43 33  
44   - @Insert("insert into SZ_AttendanceRecordsSS201911 values(#{user_id},#{school_id},#{customerId},#{usertype},#{card_num},#{card_type},#{outof},#{intime},#{cid}," +
45   - "#{func_no},#{head_image},#{classId},#{s},#{attendance_id},#{name},#{mobile},#{class_name},#{sex},#{student_type},#{systime})")
46   - int addAttenRecodrds(@Param("user_id") String user_id, @Param("school_id") String school_id, @Param("customerId") String customerId,
47   - @Param("usertype") String usertype, @Param("card_num") String card_num, @Param("card_type") String card_type,
48   - @Param("outof") String outof, @Param("intime") String intime, @Param("cid") String cid, @Param("func_no") String func_no,
49   - @Param("head_image") String head_image, @Param("classId") String classId, @Param("s") String s, @Param("attendance_id") String attendance_id,
50   - @Param("name") String name, @Param("mobile") String mobile, @Param("class_name") String class_name, @Param("sex") String sex, @Param("student_type") String student_type, @Param("systime") String systime);
51   -
52 34 @Select("select * from Face_SendSuccess where Num = #{Num} and deviceID = #{deviceID}")
53 35 List<SendRecordBean> getFaceSendSucess(@Param("Num")String Num,@Param("deviceID")String deviceID);
54 36  
... ... @@ -63,6 +45,9 @@ public interface SendRecordDao {
63 45 @Select("select * from Face_SendRecord where deviceID = #{deviceID} and Num = #{Num} and userId = #{userId}")
64 46 List<SendRecordBean> getRecordIsExit(@Param("deviceID") String deviceId, @Param("Num") String cardNum,@Param("userId") String userId);
65 47  
  48 + @Delete("delete Face_SendRecord where deviceID = #{deviceID} and Num = #{Num} and schoolId = #{schoolId}")
  49 + void deleteRecord(@Param("schoolId") Integer schoolId,@Param("deviceID") String deviceID,@Param("Num") String Num);
  50 +
66 51 @Insert("insert into Face_SendRecord values(#{deviceID},#{userId},#{num},#{name},#{time},#{schoolName},#{imgPath},#{schoolId},#{failContent},#{failType},#{userType},#{deviceType},#{status},#{channel})")
67 52 void saveFaceRecord(@Param("userId") String userId, @Param("deviceID") String deviceID, @Param("num") String num, @Param("name") String name,
68 53 @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") Integer schoolId, @Param("failContent") String failContent,
... ... @@ -77,35 +62,18 @@ public interface SendRecordDao {
77 62 @Select("select * from Face_SendRecord where schoolId = #{schoolId} and status =2")
78 63 List<SendRecordBean> getFailRecord(@Param("schoolId") Integer schoolId);
79 64  
80   - @Select("select * from Face_SendRecord where schoolId = #{schoolId} and deviceID = #{deviceId} and status =2")
81   - List<SendRecordBean> getFailRecord2(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId);
82   -
83   - @Select("select * from Face_SendRecord where schoolId = #{schoolId}")
84   - List<SendRecordBean> getFaceRecord(@Param("schoolId") Integer schoolId);
85   -
86   - @Delete("delete Face_SendRecord where deviceID = #{deviceID} and Num = #{Num} and schoolId = #{schoolId}")
87   - void deleteRecord(@Param("schoolId") Integer schoolId,@Param("deviceID") String deviceID,@Param("Num") String Num);
88   -
89 65 @Delete("delete Face_SendRecord where Num = #{Num} and schoolId = #{schoolId}")
90 66 void deleteRecordByNum(@Param("schoolId") Integer schoolId,@Param("Num") String Num);
91 67  
92   - @Delete("delete Face_SendSuccess where deviceID = #{deviceID} and Num = #{Num} and schoolId = #{schoolId}")
93   - void deleteUserFaceSuccess(@Param("schoolId") Integer schoolId,@Param("Num") String Num, @Param("deviceID") String deviceID);
94   -
95   - @Delete("delete WG_SendSuccess where deviceID = #{deviceID} and cardNum = #{cardNum} and schoolID = #{schoolID}")
96   - void deleteWGSuccess(@Param("schoolID") Integer schoolId,@Param("cardNum") String cardNum, @Param("deviceID") String deviceId);
97   -
98   -
99   - @Delete("DELETE from SZ_AttendanceRecords202101 where school_id = #{schoolId} and card_Num = #{cardNum} and card_type = #{cardType} and outof=#{outof} and intime > #{startTime} and intime < #{endTime}")
100   - void delete(@Param("schoolId") Integer schoolId,@Param("cardNum") String cardNum,@Param("cardType") Integer cardType,@Param("outof") Integer outof,@Param("startTime") String startTime,@Param("endTime") String endTime);
101   -
102 68 @Delete("DELETE from SZ_AttendanceRecordsSS202101 where school_id = #{schoolId} and card_Num = #{cardNum} and card_type = #{cardType} and outof=#{outof} and intime > #{startTime} and intime < #{endTime}")
103 69 void deleteSS(@Param("schoolId") Integer schoolId,@Param("cardNum") String cardNum,@Param("cardType") Integer cardType,@Param("outof") Integer outof,@Param("startTime") String startTime,@Param("endTime") String endTime);
104 70  
105   -
106 71 @Select("select DISTINCT num from Face_SendRecord where schoolId = #{schoolId} ")
107 72 List<String> getFaceRecordList(@Param("schoolId") Integer schoolId);
108 73  
  74 + List<SendRecordBean> getSendRecordList(@Param("schoolId") Integer schoolId,
  75 + @Param("deviceList") List<String> deviceList,
  76 + @Param("status") Integer status);
109 77 /**
110 78 * 考勤推送存储过程
111 79 * @param checkIn
... ...
cloud/haikangface/src/main/resources/mapper/usermapper.xml
... ... @@ -86,40 +86,22 @@
86 86 </select>
87 87  
88 88 <select id="getStudentByClassId" resultType="com.sincere.haikangface.bean.StudentBean">
89   - select * from SZ_V_School_Student where school_id = #{schoolId}
90   - <if test="classIds != null and classIds.size() >0">
91   - and class_id in
92   - <foreach item="item" collection="classIds" separator="," open="(" close=")" index="">
93   - #{item}
94   - </foreach>
95   - </if>
  89 + select * from SZ_V_School_Student where school_id = #{schoolId} and student_num != '' and photo !=''
96 90 <if test="studentType != null">
97 91 and student_type = #{studentType}
98 92 </if>
99   - <if test="sexList != null and sexList.size() >0">
100   - and sex in
101   - <foreach item="item" collection="sexList" separator="," open="(" close=")" index="">
  93 + <if test="classIds != null and classIds.size() >0">
  94 + and class_id in
  95 + <foreach item="item" collection="classIds" separator="," open="(" close=")" index="">
102 96 #{item}
103 97 </foreach>
104 98 </if>
105   - and student_num != '' and photo !=''
106   - </select>
107   -
108   - <select id="getStudentByKeyword" resultType="com.sincere.haikangface.bean.StudentBean">
109   - select * from SZ_V_School_Student where school_id = #{schoolId}
110   - <if test="studentType != null">
111   - and student_type = #{studentType}
112   - </if>
113 99 <if test="sexList != null and sexList.size() >0">
114 100 and sex in
115 101 <foreach item="item" collection="sexList" separator="," open="(" close=")" index="">
116 102 #{item}
117 103 </foreach>
118 104 </if>
119   - <if test="keyword != null and keyword !=''">
120   - and class_name like concat('%', #{keyword}, '%')
121   - </if>
122   - and student_num != '' and photo !=''
123 105 </select>
124 106  
125 107 <select id="getStudentCardGroup" resultType="com.sincere.haikangface.bean.StudentBean">
... ... @@ -162,7 +144,6 @@
162 144 (#{userId},#{customerId}, #{studentType}, #{userType}, #{name}, #{classId}, #{className}, #{oldCard}, #{card},#{schoolId},#{isNew},#{updateType}, #{addTime}, #{sex}, #{face}, #{studentCode}, #{mobile})
163 145 </insert>
164 146  
165   -
166 147 <select id="getStudentWithCard" resultType="com.sincere.haikangface.bean.StudentBean">
167 148 select Top(1)* from SZ_V_School_Student where student_num = #{card}
168 149 <if test="schoolId !=null">
... ... @@ -177,7 +158,7 @@
177 158 </if>
178 159 </select>
179 160  
180   - <select id="getStudentCByUserId" resultType="com.sincere.haikangface.bean.StudentBean">
  161 + <select id="getStudentByUserId" resultType="com.sincere.haikangface.bean.StudentBean">
181 162 select Top(1) * from SZ_V_School_Student where user_id = #{userId}
182 163 <if test="schoolId !=null">
183 164 and school_id = #{schoolId}
... ... @@ -191,32 +172,6 @@
191 172 </if>
192 173 </select>
193 174  
194   - <resultMap id="BaseResultMap" type="com.sincere.haikangface.bean.test.SaveStudentBak">
195   - <!--
196   - WARNING - @mbg.generated
197   - -->
198   - <id column="id" jdbcType="INTEGER" property="id"/>
199   - <result column="name" property="name"/>
200   - <result column="user_id" property="userId"/>
201   - <result column="card_num" property="cardNum"/>
202   - <result column="class_name" property="className"/>
203   - <result column="school_Id" property="schoolId"/>
204   - <result column="status" property="status"/>
205   - <result column="client_id" property="clientId"/>
206   - </resultMap>
207   -
208   - <insert id="insertStudent" parameterType="com.sincere.haikangface.bean.test.SaveStudentBak">
209   - insert into sz_student_bak values (#{name},#{userId},#{cardNum},#{clientId},#{className},#{status},#{schoolId})
210   - </insert>
211   -
212   - <select id="selectStudentList" resultMap="BaseResultMap">
213   - select * from sz_student_bak where status = 2
214   - </select>
215   -
216   - <update id="updateStudent" parameterType="java.lang.Integer">
217   - update sz_student_bak set status = 1 where id = #{id}
218   - </update>
219   -
220 175 <select id="getRoomBySchoolId" resultType="java.lang.Integer">
221 176 select Id from ss_room where schoolId = #{schoolId} and pId = #{groupId}
222 177 </select>
... ...
cloud/haikangface/src/main/resources/xiaoanmapper/usermapper.xml
... ... @@ -13,4 +13,17 @@
13 13 #{out,mode=OUT,jdbcType=VARCHAR,resultMap=resultMap},#{isSuccess,mode=OUT,jdbcType=INTEGER,resultMap=resultMap}
14 14 )}
15 15 </insert>
  16 +
  17 + <select id="getSendRecordList" resultType="com.sincere.haikangface.bean.SendRecordBean">
  18 + select * from Face_SendRecord where schoolId = #{schoolId} and status =2
  19 + <if test="status != null">
  20 + and status = #{status}
  21 + </if>
  22 + <if test="deviceList != null and deviceList.size() >0">
  23 + and deviceID in
  24 + <foreach item="item" collection="deviceList" separator="," open="(" close=")" index="">
  25 + #{item}
  26 + </foreach>
  27 + </if>
  28 + </select>
16 29 </mapper>
... ...
cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java
... ... @@ -103,7 +103,7 @@ public class HaikangfaceApplicationTests {
103 103 saveStudentBak.setName(name);
104 104 saveStudentBak.setClassName(className);
105 105 saveStudentBak.setStatus(2);
106   - userDao.insertStudent(saveStudentBak);
  106 +// userDao.insertStudent(saveStudentBak);
107 107 }
108 108 }
109 109 });
... ...
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java
... ... @@ -34,12 +34,12 @@ public class DataSourceConfig {
34 34 public DataSource dataSource3() {
35 35 return DataSourceBuilder.create().build();
36 36 }
37   -
38   - @Bean(name = "update")
39   - @ConfigurationProperties(prefix = "spring.datasource.update")
40   - public DataSource dataSource4() {
41   - return DataSourceBuilder.create().build();
42   - }
  37 +//
  38 +// @Bean(name = "update")
  39 +// @ConfigurationProperties(prefix = "spring.datasource.update")
  40 +// public DataSource dataSource4() {
  41 +// return DataSourceBuilder.create().build();
  42 +// }
43 43  
44 44 @Bean(name="dynamicDataSource")
45 45 @Primary //优先使用,多数据源
... ... @@ -48,7 +48,7 @@ public class DataSourceConfig {
48 48 DataSource master = dataSource1();
49 49 DataSource slave = dataSource2();
50 50 DataSource yxy = dataSource3();
51   - DataSource update = dataSource4();
  51 +// DataSource update = dataSource4();
52 52 //设置默认数据源
53 53 dynamicDataSource.setDefaultTargetDataSource(master);
54 54 //配置多数据源
... ... @@ -56,7 +56,7 @@ public class DataSourceConfig {
56 56 map.put(DataSourceType.Master.getName(), master); //key需要跟ThreadLocal中的值对应
57 57 map.put(DataSourceType.Slave.getName(), slave);
58 58 map.put(DataSourceType.Yxy.getName(), yxy);
59   - map.put(DataSourceType.Update.getName(), update);
  59 +// map.put(DataSourceType.Update.getName(), update);
60 60 dynamicDataSource.setTargetDataSources(map);
61 61 return dynamicDataSource;
62 62 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
... ... @@ -23,7 +23,7 @@ public class SyncJob {
23 23 YXYReadService yxyReadService ;
24 24  
25 25 // @Scheduled(cron = "30 1 22 * * ? ")
26   - @Scheduled(fixedDelay = 220 * 60 * 1000)
  26 + @Scheduled(fixedDelay = 60 * 60 * 1000)
27 27 public void Sync(){
28 28 //翼校通的同步 之后还有钉钉的同步等等
29 29 yxyReadService.sync();
... ...