diff --git a/cloud/common/src/main/java/com/sincere/common/dto/admin/QuestionBean.java b/cloud/common/src/main/java/com/sincere/common/dto/admin/QuestionBean.java new file mode 100644 index 0000000..923b397 --- /dev/null +++ b/cloud/common/src/main/java/com/sincere/common/dto/admin/QuestionBean.java @@ -0,0 +1,275 @@ +package com.sincere.common.dto.admin; + +import java.io.Serializable; + +public class QuestionBean implements Serializable { + + private String ID; + private String Question; + + private String Qtype; + + private String Answer; + + private String CorrectAnswer; + + private String Analysis; + + private String State; + + private String Intime; + + private String ExamineFlag; + + private String ExamineUserId; + + private String CreateUserId; + + private String SubjectId; + + private String SchoolId; + + private String DifficulteId; + + private String KnowledgeId; + + private String ChapterId; + + private String GradeId; + + private String SourceId; + + private String OrderId; + + private String SId; + + private String StemId; + + private String AutomaticCorrection; + + private String PkgId; + + private String PkgType; + + public String getQuestion() { + return Question; + } + + public void setQuestion(String question) { + Question = question; + } + + public String getQtype() { + return Qtype; + } + + public void setQtype(String qtype) { + Qtype = qtype; + } + + public String getAnswer() { + return Answer; + } + + public void setAnswer(String answer) { + Answer = answer; + } + + public String getCorrectAnswer() { + return CorrectAnswer; + } + + public void setCorrectAnswer(String correctAnswer) { + CorrectAnswer = correctAnswer; + } + + public String getAnalysis() { + return Analysis; + } + + public void setAnalysis(String analysis) { + Analysis = analysis; + } + + public String getState() { + return State; + } + + public void setState(String state) { + State = state; + } + + public String getIntime() { + return Intime; + } + + public void setIntime(String intime) { + Intime = intime; + } + + public String getExamineFlag() { + return ExamineFlag; + } + + public void setExamineFlag(String examineFlag) { + ExamineFlag = examineFlag; + } + + public String getExamineUserId() { + return ExamineUserId; + } + + public String getID() { + return ID; + } + + public void setID(String ID) { + this.ID = ID; + } + + public void setExamineUserId(String examineUserId) { + ExamineUserId = examineUserId; + } + + public String getCreateUserId() { + return CreateUserId; + } + + public void setCreateUserId(String createUserId) { + CreateUserId = createUserId; + } + + public String getSubjectId() { + return SubjectId; + } + + public void setSubjectId(String subjectId) { + SubjectId = subjectId; + } + + public String getSchoolId() { + return SchoolId; + } + + public void setSchoolId(String schoolId) { + SchoolId = schoolId; + } + + public String getDifficulteId() { + return DifficulteId; + } + + public void setDifficulteId(String difficulteId) { + DifficulteId = difficulteId; + } + + public String getKnowledgeId() { + return KnowledgeId; + } + + public void setKnowledgeId(String knowledgeId) { + KnowledgeId = knowledgeId; + } + + public String getChapterId() { + return ChapterId; + } + + public void setChapterId(String chapterId) { + ChapterId = chapterId; + } + + public String getGradeId() { + return GradeId; + } + + public void setGradeId(String gradeId) { + GradeId = gradeId; + } + + public String getSourceId() { + return SourceId; + } + + public void setSourceId(String sourceId) { + SourceId = sourceId; + } + + public String getOrderId() { + return OrderId; + } + + public void setOrderId(String orderId) { + OrderId = orderId; + } + + public String getSId() { + return SId; + } + + public void setSId(String SId) { + this.SId = SId; + } + + public String getStemId() { + return StemId; + } + + public void setStemId(String stemId) { + StemId = stemId; + } + + public String getAutomaticCorrection() { + return AutomaticCorrection; + } + + public void setAutomaticCorrection(String automaticCorrection) { + AutomaticCorrection = automaticCorrection; + } + + public String getPkgId() { + return PkgId; + } + + public void setPkgId(String pkgId) { + PkgId = pkgId; + } + + public String getPkgType() { + return PkgType; + } + + public void setPkgType(String pkgType) { + PkgType = pkgType; + } + + @Override + public String toString() { + return "QuestionBean{" + + "ID='" + ID + '\'' + + ", Question='" + Question + '\'' + + ", Qtype='" + Qtype + '\'' + + ", Answer='" + Answer + '\'' + + ", CorrectAnswer='" + CorrectAnswer + '\'' + + ", Analysis='" + Analysis + '\'' + + ", State='" + State + '\'' + + ", Intime='" + Intime + '\'' + + ", ExamineFlag='" + ExamineFlag + '\'' + + ", ExamineUserId='" + ExamineUserId + '\'' + + ", CreateUserId='" + CreateUserId + '\'' + + ", SubjectId='" + SubjectId + '\'' + + ", SchoolId='" + SchoolId + '\'' + + ", DifficulteId='" + DifficulteId + '\'' + + ", KnowledgeId='" + KnowledgeId + '\'' + + ", ChapterId='" + ChapterId + '\'' + + ", GradeId='" + GradeId + '\'' + + ", SourceId='" + SourceId + '\'' + + ", OrderId='" + OrderId + '\'' + + ", SId='" + SId + '\'' + + ", StemId='" + StemId + '\'' + + ", AutomaticCorrection='" + AutomaticCorrection + '\'' + + ", PkgId='" + PkgId + '\'' + + ", PkgType='" + PkgType + '\'' + + '}'; + } +} diff --git a/cloud/dahua/pom.xml b/cloud/dahua/pom.xml index 37d181b..e2a3818 100644 --- a/cloud/dahua/pom.xml +++ b/cloud/dahua/pom.xml @@ -31,12 +31,36 @@ - + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.10.0 + compile + + + org.apache.logging.log4j + log4j-core + 2.10.0 + compile + + + org.apache.logging.log4j + log4j-jul + 2.10.0 + compile + + + org.slf4j + jul-to-slf4j + 1.7.25 + compile + org.springframework.boot diff --git a/cloud/dahua/src/main/java/com/example/dahua/MyTask.java b/cloud/dahua/src/main/java/com/example/dahua/MyTask.java index aecec4a..00c1af8 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/MyTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/MyTask.java @@ -1,7 +1,12 @@ package com.example.dahua; +import com.example.dahua.Gate.Gate; import com.example.dahua.alarmListen.AlarmListenModule; +import com.example.dahua.bean.CardBean; import com.example.dahua.bean.DeviceInfoBean; +import com.example.dahua.bean.TeacherBean; +import com.example.dahua.bean.UserInfoBean; +import com.example.dahua.dao.UserDao; import com.example.dahua.lib.NetSDKLib; import com.example.dahua.lib.ToolKits; import com.example.dahua.lib.Utils; @@ -51,15 +56,17 @@ public class MyTask implements ApplicationRunner { //在线设备信息集合 private List deviceInfoBeans = new ArrayList<>(); - //存放设备的id和IP - public static Map devMap = new HashMap<>(); - //存放登录句柄 public static Map lLongMap = new HashMap<>(); @Autowired SendRecordDao sendRecordDao; + @Autowired + UserDao userDao; + + public boolean isHasNewDevice = false;//判断是否有新设备上线 + @Override public void run(ApplicationArguments args) throws Exception { // 121.40.109.21 @@ -72,7 +79,6 @@ public class MyTask implements ApplicationRunner { } - /** * 设备自注册 */ @@ -95,7 +101,9 @@ public class MyTask implements ApplicationRunner { attendanceService.updateConnectStateWithDevid(0, deviceId); GateModule.stopRealLoadPic(lLongMap.get(deviceId)); lLongMap.remove(deviceId); - devMap.remove(deviceId); +// devMap.remove(deviceId); + removeDevice(deviceId); + isHasNewDevice = true; } // AutoRegisterModule.logout() // 断线提示 @@ -111,8 +119,17 @@ public class MyTask implements ApplicationRunner { String deviceId = getDeviceId(pchDVRIP, nDVRPort); if (!StringUtils.isEmpty(deviceId)) { attendanceService.updateConnectStateWithDevid(1, deviceId); - devMap.put(deviceId,""); - lLongMap.put(deviceId,m_hLoginHandle); +// devMap.put(deviceId,""); + DeviceInfoBean deviceInfoBean = new DeviceInfoBean(); + deviceInfoBean.setDevcieId(deviceId); + deviceInfoBean.setDeviceIp(pchDVRIP); + deviceInfoBean.setDevicePort(nDVRPort); + deviceInfoBean.setLoginHandle(m_hLoginHandle); + deviceInfoBean.setPassword(password); + deviceInfoBean.setUsername(strUser); + deviceInfoBeans.add(deviceInfoBean); + lLongMap.put(deviceId, m_hLoginHandle); + isHasNewDevice = true; } } } @@ -134,6 +151,24 @@ public class MyTask implements ApplicationRunner { return ""; } + /** + * 移除设备 + * + * @param deviceId + */ + private void removeDevice(String deviceId) { + + DeviceInfoBean deviceInfoBean = null; + + + for (DeviceInfoBean dev : + deviceInfoBeans) { + if (dev.getDevcieId().equals(deviceId)) deviceInfoBean = dev; + } + + if (null != deviceInfoBean) deviceInfoBeans.remove(deviceInfoBean); + } + @Autowired private AttendanceService attendanceService;//设备控制服务 @@ -170,20 +205,17 @@ public class MyTask implements ApplicationRunner { * 主动注册调用的登录接口,获取登录句柄 */ NetSDKLib.LLong loginHandleLong = AutoRegisterModule.login(pIp, wPort, strUser, password, deviceId); -// reloadPicCallBack.reloadCallBack(loginHandleLong); -// AlarmListenModule.startListen(cbMessage,loginHandleLong); - FileUtils.getInstance().writeLogs("设备注册:"+deviceId+" 登录句柄:"+loginHandleLong,FileUtils.devices); +// FileUtils.getInstance().writeLogs("设备注册:"+deviceId+" 登录句柄:"+loginHandleLong,FileUtils.devices); if (loginHandleLong.longValue() != 0) { -// System.out.println(String.format("Login Success [Device IP %s][port %s][DeviceID %s][loginHandleLong %s]\n", pIp, -// wPort, deviceId,loginHandleLong)); - devMap.put(deviceId, pIp + "," + wPort); - lLongMap.put(deviceId,loginHandleLong); + lLongMap.put(deviceId, loginHandleLong); + isHasNewDevice = true; String inTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); int index = attendanceService.insert(deviceId, "22", pIp, wPort + "", inTime, "-1", "1"); DeviceInfoBean deviceInfoBean = new DeviceInfoBean(); deviceInfoBean.setDevcieId(deviceId); deviceInfoBean.setDeviceIp(pIp); deviceInfoBean.setDevicePort(wPort); + deviceInfoBean.setLoginHandle(loginHandleLong); deviceInfoBeans.add(deviceInfoBean); } else { @@ -199,52 +231,85 @@ public class MyTask implements ApplicationRunner { return 0; } } - private ReloadPicCallBack reloadPicCallBack = new ReloadPicCallBack() { - @Override - public void reloadCallBack(NetSDKLib.LLong loginHandleLong) { - //注册成功后进入订阅模式 - GateModule.realLoadPic(0, analyzerCallback,loginHandleLong); + + public void reloadPic() { + + /* Set set = lLongMap.keySet(); + Iterator iterator = set.iterator(); + + while (iterator.hasNext()){ + String deviceId= iterator.next(); + System.out.println("deviceId:"+deviceId+" llong:"+lLongMap.get(deviceId)); + GateModule.stopRealLoadPic(lLongMap.get(deviceId)); + GateModule.realLoadPic(0,analyzerCallback,lLongMap.get(deviceId)); + }*/ + + for (DeviceInfoBean dev : + deviceInfoBeans) { + System.out.println("dev:" + dev.toString() + " -------llong:" + lLongMap.get(dev.getDevcieId())); + FileUtils.getInstance().writeLogs(dev.getDevcieId() + "------" + lLongMap.get(dev.getDevcieId()), FileUtils.device_login); + if (lLongMap.get(dev.getDevcieId()).intValue() > 0) + GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); + } - }; - public interface ReloadPicCallBack{ - void reloadCallBack(NetSDKLib.LLong loginHandleLong); + + isHasNewDevice = false; } //智能订阅 private AnalyzerDataCB analyzerCallback = new AnalyzerDataCB(); + private class AnalyzerDataCB implements NetSDKLib.fAnalyzerDataCallBack { private BufferedImage gateBufferedImage = null; public int invoke(NetSDKLib.LLong lAnalyzerHandle, int dwAlarmType, Pointer pAlarmInfo, Pointer pBuffer, int dwBufSize, - Pointer dwUser, int nSequence, Pointer reserved) - { + Pointer dwUser, int nSequence, Pointer reserved) { if (lAnalyzerHandle.longValue() == 0 || pAlarmInfo == null) { return -1; } - System.out.println("sda"); - File path = new File("./GateSnapPicture/"); + byte[] bufferBytes = new byte[dwBufSize]; + + pBuffer.read(0, bufferBytes, 0, dwBufSize); + + + File path = new File("E:\\wwwhtdocs\\SmartCampus\\face17e50\\FaceRecoder"); if (!path.exists()) { path.mkdir(); } ///< 门禁事件 - if(dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { + if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); ToolKits.GetPointerData(pAlarmInfo, msg); - // 保存图片,获取图片缓存 - String snapPicPath = path + "\\" + System.currentTimeMillis() + "GateSnapPicture.jpg"; // 保存图片地址 + String snapPicPath = path + "\\" + System.currentTimeMillis() + ".png"; // 保存图片地址 byte[] buffer = pBuffer.getByteArray(0, dwBufSize); ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); try { + System.out.println("sda:" + new String(msg.szCardNo) + " 抓拍照片存储地址:" + new String(msg.szSnapURL, "GBK").trim()); gateBufferedImage = ImageIO.read(byteArrInputGlobal); - if(gateBufferedImage != null) { - ImageIO.write(gateBufferedImage, "jpg", new File(snapPicPath)); + if (gateBufferedImage != null) { + ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); } + String card = new String(msg.szCardNo).trim(); + if (!StringUtils.isEmpty(card)) { + card=cardNo(card); + CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + snapPicPath = snapPicPath.replace("E:\\wwwhtdocs\\SmartCampus", "http://campus.myjxt.com"); + if (cardBean.getType() == 0) {//老师 + TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); + sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card); + } else if (cardBean.getType() == 2) {//学生 + UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); + sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card); + } + } + } catch (IOException e2) { e2.printStackTrace(); } @@ -262,60 +327,27 @@ public class MyTask implements ApplicationRunner { } } + /** + * 卡号两两取反 + * + * @param cardDex + * @return + */ + public String cardNo(String cardDex) { - private fAlarmDataCB cbMessage = new fAlarmDataCB(); - - - private class fAlarmDataCB implements NetSDKLib.fMessCallBack{ - - @Override - public boolean invoke(int lCommand, NetSDKLib.LLong lLoginID, - Pointer pStuEvent, int dwBufLen, String strDeviceIP, - NativeLong nDevicePort, Pointer dwUser) { - - /* byte[] alarm = new byte[dwBufLen]; - pStuEvent.read(0, alarm, 0, dwBufLen); - try { - String alarmStr=new String(alarm,"GBK"); - System.out.println("报警信息:"+alarmStr); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - - switch (lCommand) { - case NetSDKLib.NET_ALARM_ALARM_EX: - case NetSDKLib.NET_MOTION_ALARM_EX: - case NetSDKLib.NET_VIDEOLOST_ALARM_EX: - case NetSDKLib.NET_SHELTER_ALARM_EX: - case NetSDKLib.NET_DISKFULL_ALARM_EX: - case NetSDKLib.NET_DISKERROR_ALARM_EX: { - String content = ""; - for (int i = 0; i < dwBufLen; i++) { - if (alarm[i] == 1) { - byte c = alarm[i]; - content+=String.valueOf(c); -// AlarmEventInfo alarmEventInfo = new AlarmEventInfo(i, lCommand, AlarmStatus.ALARM_START); -// if (!data.contains(alarmEventInfo)) { -// data.add(alarmEventInfo); -// eventQueue.postEvent(new AlarmListenEvent(target, alarmEventInfo)); -// } - }else { -// AlarmEventInfo alarmEventInfo = new AlarmEventInfo(i, lCommand, AlarmStatus.ALARM_STOP); -// if (data.remove(alarmEventInfo)) { -// eventQueue.postEvent(new AlarmListenEvent(target, alarmEventInfo)); -// } - } - } - - System.out.println("content:"+content); - break; - } - default: - break; + String cardR = ""; + int length = cardDex.length(); + if (length != 8) { + System.out.println("卡号格式不正确:" + cardDex); + return cardDex; + } + while (length > 0) { + length -= 2; + cardR += cardDex.substring(length, length + 2); + } - }*/ + return cardR; - return true; - } } + } diff --git a/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java b/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java index 2d89b70..bd6bfc6 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java @@ -1,5 +1,6 @@ package com.example.dahua.async; +import com.example.dahua.MyTask; import com.example.dahua.bean.SendRecordBean; import com.example.dahua.bean.StudentBean; import com.example.dahua.bean.UserInfoBean; @@ -36,7 +37,6 @@ import java.util.List; @EnableScheduling public class MyScheduledTask { - @Autowired SendRecordDao sendRecordDao; @@ -44,16 +44,19 @@ public class MyScheduledTask { UserDao userDao; @Autowired - SendUserInfoTask myTask; + SendUserInfoTask sendUserInfoTask; + + @Autowired + MyTask myTasks; - @Value("${haikangpic}") - private String haikangpic; +// @Value("${haikangpic}") +// private String haikangpic; - public boolean isSendHaikang = false; + public static boolean isSendHaikang = false; - public boolean isSendWeigeng = false; + public static boolean isSendWeigeng = false; - public boolean isSendDahua = false; + public static boolean isSendDahua = false; private boolean isClose = true, isCloseYT = true;//判断是否关机 @@ -92,8 +95,8 @@ public class MyScheduledTask { isClose = false; close(30, 479);//关闭 } - if (hour >= 9 && hour < 11) { + if (hour >= 9 && hour < 11) { dealData(); } else if (hour >= 13 && hour < 14) { dealData(); @@ -101,6 +104,7 @@ public class MyScheduledTask { dealData(); } + if (myTasks.isHasNewDevice)myTasks.reloadPic(); } @@ -170,7 +174,7 @@ public class MyScheduledTask { //System.out.println("isSendWeigeng:"+isSendWeigeng+"isSendHaikang:"+isSendHaikang+"isSendDahua:"+isSendDahua); if (!isSendWeigeng) { isSendWeigeng = true; - myTask.addWeiGen(); + sendUserInfoTask.addWeiGen(); } /** @@ -178,7 +182,7 @@ public class MyScheduledTask { */ if (!isSendHaikang) { isSendHaikang = true; - myTask.addHaikangface(); + sendUserInfoTask.addHaikangface(); } /** @@ -186,7 +190,7 @@ public class MyScheduledTask { */ if (!isSendDahua) { isSendDahua = true; - myTask.addDahuaFace(); + sendUserInfoTask.addDahuaFace(); } } diff --git a/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java b/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java index 7e89a5e..7dc0b66 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java @@ -43,9 +43,6 @@ public class SendUserInfoTask { @Autowired SendRecordDao sendRecordDao; - @Autowired - MyScheduledTask myScheduledTask; - @Async("taskExecutor") public void doTaskOne(String file, List attendanceBeans, UserInfoBean userInfoBean, String schoolId, int failType) throws Exception { File studentFile = new File(file); @@ -298,7 +295,7 @@ public class SendUserInfoTask { NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(attendanceBean.getClint_id()); // System.out.println("loginHandleLong:" + loginHandleLong + MyTask.lLongMap.toString() + " 设备ID:" + attendanceBean.getClint_id()); - +// System.out.println("loginHandleLong:" +loginHandleLong); if (loginHandleLong == null) { FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); @@ -317,11 +314,6 @@ public class SendUserInfoTask { GateModule.deleteCard(bCardFlags, loginHandleLong); userDao.deleteRecordNo(user_id, bCardFlags); -// boolean update = GateModule.modifyCard(bCardFlags, cardNum, userInfoBean.getUser_id(), userInfoBean.getName(), "123456" -// , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 0 -// , 1, startTime, endTime, loginHandleLong); -// System.out.println("update:" + update); - bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 0 , 1, startTime, endTime, loginHandleLong); @@ -378,7 +370,8 @@ public class SendUserInfoTask { // 添加卡信息和人脸失败 if (bCardFlags == -1 && !bFaceFalgs) { FileUtils.getInstance().writeLogs("下发人脸和卡号失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt); - System.out.println("添加卡信息和人脸失败"); +// System.out.println("添加卡信息和人脸失败"); + System.out.println("下发人脸和卡号失败" + "sendRecordBean:" + sendRecordBean); sendRecordBean.setFailContent("下发人脸和卡号失败"); sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 7);//更新下发失败状态 sendRecordBean.setFailType(8); @@ -425,7 +418,7 @@ public class SendUserInfoTask { // } } - private String cardNo(String cardDex) { + public String cardNo(String cardDex) { String cardR = ""; int length = cardDex.length(); @@ -438,7 +431,6 @@ public class SendUserInfoTask { cardR += cardDex.substring(length, length + 2); } -// return Long.parseLong(cardR, 16) + ""; return cardR; } @@ -520,7 +512,7 @@ public class SendUserInfoTask { String customerID = customerIDs.get(i); addKard(customerID, "2");//微耕 } - myScheduledTask.isSendWeigeng = false; + MyScheduledTask.isSendWeigeng = false; } String url = "http://campus.myjxt.com/api/OneCard/UpdateDataBK"; @@ -580,7 +572,7 @@ public class SendUserInfoTask { System.out.println("下发失败:" + url); } } - myScheduledTask.isSendHaikang = false; + MyScheduledTask.isSendHaikang = false; } @@ -611,7 +603,7 @@ public class SendUserInfoTask { } } - myScheduledTask.isSendDahua = false; + MyScheduledTask.isSendDahua = false; } private void senfaceToDahua(SendRecordBean sendRecordBean) { diff --git a/cloud/dahua/src/main/java/com/example/dahua/bean/CardBean.java b/cloud/dahua/src/main/java/com/example/dahua/bean/CardBean.java new file mode 100644 index 0000000..bf680be --- /dev/null +++ b/cloud/dahua/src/main/java/com/example/dahua/bean/CardBean.java @@ -0,0 +1,45 @@ +package com.example.dahua.bean; + +import java.io.Serializable; + +public class CardBean implements Serializable { + + private String num; + + private int type;//0:老师;2:学生 + + private String user_id;//student_id或者teacher_id + + public String getNum() { + return num; + } + + public void setNum(String num) { + this.num = num; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getUser_id() { + return user_id; + } + + public void setUser_id(String user_id) { + this.user_id = user_id; + } + + @Override + public String toString() { + return "CardBean{" + + "num='" + num + '\'' + + ", type=" + type + + ", user_id='" + user_id + '\'' + + '}'; + } +} diff --git a/cloud/dahua/src/main/java/com/example/dahua/bean/DeviceInfoBean.java b/cloud/dahua/src/main/java/com/example/dahua/bean/DeviceInfoBean.java index 320f21c..2ec2d67 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/bean/DeviceInfoBean.java +++ b/cloud/dahua/src/main/java/com/example/dahua/bean/DeviceInfoBean.java @@ -52,4 +52,16 @@ public class DeviceInfoBean { public void setLoginHandle(NetSDKLib.LLong loginHandle) { this.loginHandle = loginHandle; } + + @Override + public String toString() { + return "DeviceInfoBean{" + + "devcieId='" + devcieId + '\'' + + ", username='" + username + '\'' + + ", password='" + password + '\'' + + ", deviceIp='" + deviceIp + '\'' + + ", port=" + port + + ", loginHandle=" + loginHandle + + '}'; + } } diff --git a/cloud/dahua/src/main/java/com/example/dahua/control/HelpControl.java b/cloud/dahua/src/main/java/com/example/dahua/control/HelpControl.java deleted file mode 100644 index 6b565c5..0000000 --- a/cloud/dahua/src/main/java/com/example/dahua/control/HelpControl.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.example.dahua.control; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@RestController("/help/") -@Api(tags = "辅助工具") -@RequestMapping("/help/") -public class HelpControl { - - - @RequestMapping(value = "createFile", method = RequestMethod.GET) - @ApiOperation(value = "生成文件") - @ApiImplicitParams({@ApiImplicitParam(name = "file", value = "根目录")}) - public String createFile(@RequestParam("file") String file) { -// System.out.println("count:" + (count++)); - - //第一步,创建一个workbook对应一个excel文件 - HSSFWorkbook workbook = new HSSFWorkbook(); - - File file1 = new File(file); - - File[] files = file1.listFiles(); - - List list = new ArrayList<>(); - - for (int i = 0; i < files.length; i++) { - File file2 = files[i]; - - if (file2.isDirectory()) { - - File[] file3 = file2.listFiles(); - for (int j = 0; j < file3.length; j++) { - File file4 = file3[j]; - String fileName = file4.getName(); - String fileDirName = file2.getName(); - list.add(fileDirName+","+fileName); - } - - }else if (file2.isFile()){ - String fileName = file2.getName() ; - String fileDirName = file1.getName(); - list.add(fileDirName+","+fileName); - } - - } - - - return writeToExcel(workbook,"文件",list).getAbsolutePath(); - } - - - private File writeToExcel(HSSFWorkbook workbook, String sheetName, List values) { - //第二部,在workbook中创建一个sheet对应excel中的sheet - HSSFSheet sheet = workbook.createSheet(sheetName); - //第三部,在sheet表中添加表头第0行,老版本的poi对sheet的行列有限制 - HSSFRow row = sheet.createRow(0); - //第四步,创建单元格,设置表头 - HSSFCell cell = null; - for (int i = 0; i < 2; i++) { - cell = row.createCell(i); - if (i == 0) - cell.setCellValue("目录名称"); - else if (i==1) - cell.setCellValue("文件名称"); - } - - //第五步,写入数据 - for (int i = 0; i < values.size(); i++) { - - HSSFRow row1 = sheet.createRow(i + 1); - String value = values.get(i); - - row1.createCell(0).setCellValue(value.split(",")[0]); - row1.createCell(1).setCellValue(value.split(",")[1]); - } - - //将文件保存到指定的位置 - try { - File file = new File("./file/"); - if (!file.exists()) file.mkdirs(); - - File file1 = new File(file.getAbsolutePath(), sheetName + ".xls"); - if (!file1.exists()) file1.createNewFile(); - FileOutputStream fos = new FileOutputStream(file1); - workbook.write(fos); - System.out.println("写入成功"); - fos.close(); - return file1; - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java b/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java index 8be101a..efe15df 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java +++ b/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java @@ -1,5 +1,6 @@ package com.example.dahua.control; +import com.example.dahua.MyTask; import com.example.dahua.async.ImageUtils; import com.example.dahua.async.SendUserInfoTask; import com.example.dahua.lib.CompressPic; @@ -49,8 +50,11 @@ public class UserControl { @Autowired SendUserInfoTask sendUserInfoTask; - @Value("${haikangfaceurl}") - private String haikangfaceurl; + @Autowired + MyTask myTasks; + +// @Value("${haikangfaceurl}") +// private String haikangfaceurl; @RequestMapping(value = "uploadImgAndUserInfo", method = RequestMethod.GET) @ApiOperation(value = "上传用户信息") @@ -369,7 +373,6 @@ public class UserControl { sendUserInfoTask.deleteFace(cardNum, deviceId); - } @@ -381,6 +384,14 @@ public class UserControl { } + @RequestMapping(value = "startListener", method = RequestMethod.GET) + @ApiOperation("开启监听") + public void startListener() { + + myTasks.reloadPic(); + + } + @RequestMapping(value = "compic", method = RequestMethod.GET) @ApiOperation("图片压缩") @@ -440,9 +451,10 @@ public class UserControl { e.printStackTrace(); } return "解析失败"; - } + + private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.12f07855bae00621f319d10f00f6aaa2.2592000.1576727813.282335-15990462"; private String getAnswer(String imgUrl, int type) { diff --git a/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java b/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java index 5a12e3c..467ffa3 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java +++ b/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java @@ -1,9 +1,6 @@ package com.example.dahua.dao; -import com.example.dahua.bean.AttendanceBean; -import com.example.dahua.bean.StudentBean; -import com.example.dahua.bean.TeacherBean; -import com.example.dahua.bean.UserInfoBean; +import com.example.dahua.bean.*; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -26,8 +23,8 @@ public interface UserDao { @Select(" select * from SZ_V_School_Teacher where school_id = #{school_id} and num = #{num}") TeacherBean getTeacher(@Param("school_id")String school_id, @Param("num")String num); - @Select(" select * from SZ_V_School_Teacher where school_id = 562 and teacher_num = #{teacher_num}") - List getTeachers( @Param("teacher_num")String teacher_num); + @Select(" select Top(1)* from SZ_V_School_Teacher where teacher_id = #{teacher_id}") + TeacherBean getTeacherWithId( @Param("teacher_id")String teacher_id); @Select(" select * from SZ_V_School_Teacher where school_id = 562 and name = #{name}") List getTeachersWithName( @Param("name")String name); @@ -62,9 +59,8 @@ public interface UserDao { @Select(" select studentcode from SZ_V_School_Student where student_id = #{customerid}") String getStudentCode(@Param("customerid") String customerid); - - @Select(" select * from SZ_V_School_Student where studentcode = #{studentcode}") - UserInfoBean getStudentId(@Param("studentcode") String student_num); + @Select(" select * from SZ_V_School_Student where student_id = #{student_id}") + UserInfoBean getStudentWithid(@Param("student_id") String student_id); @Select(" select * from SZ_V_School_Student where student_num = #{student_num} and name = #{name}") UserInfoBean getStudent(@Param("student_num") String student_num,@Param("name") String name); @@ -95,4 +91,7 @@ public interface UserDao { @Select("select StudentId from SS_RoomNumber where Pid in (select id from SS_Room where SchoolId = 479)") List getStudentIds(); + @Select("select * from SZ_V_Card where num=#{num}") + CardBean getCards(@Param("num")String num); + } diff --git a/cloud/dahua/src/main/java/com/example/dahua/lib/CompressPic.java b/cloud/dahua/src/main/java/com/example/dahua/lib/CompressPic.java index a738946..93fc70c 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/lib/CompressPic.java +++ b/cloud/dahua/src/main/java/com/example/dahua/lib/CompressPic.java @@ -24,10 +24,10 @@ public class CompressPic { int width = bufferedImage.getWidth(null); int height = bufferedImage.getHeight(null); long fileLength = file.length(); - if ((fileLength / 1024) < 64) { + if ((fileLength / 1024) < 128) { writeImgToFile(bufferedImage, width, height, targetPath); } else - while ((fileLength / 1024) >= 64) { + while ((fileLength / 1024) >= 128) { width = (int) (width * (1 - cutPercent)); height = (int) (height * (1 - cutPercent)); diff --git a/cloud/dahua/src/main/java/com/example/dahua/utils/FileUtils.java b/cloud/dahua/src/main/java/com/example/dahua/utils/FileUtils.java index 98ba1bf..cda7d0b 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/utils/FileUtils.java +++ b/cloud/dahua/src/main/java/com/example/dahua/utils/FileUtils.java @@ -12,6 +12,7 @@ public class FileUtils { public static String checkFail = "检测失败.txt"; public static String checkSuc = "检测成功.txt"; + public static String device_login="设备登录id.txt"; private static FileUtils fileUtils; private String filePath = "./log/";//日志记录目录 diff --git a/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java b/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java index 46edf6f..eb754db 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java +++ b/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java @@ -71,5 +71,10 @@ public interface SendRecordDao { @Select("select * from Face_SendFail where schoolId = #{schoolId} and userType = #{userType} and deviceID = #{deviceID}") List getFaceFails(@Param("userType")int userType,@Param("schoolId")int schoolId,@Param("deviceID")String deviceID); + + @Insert("insert into Face_Recoder values(#{deviceId},#{user_id},#{name},#{imgurl},#{inOrOut},#{time},#{cardNum})") + void addFaceRecoder(@Param("deviceId") String deviceId, @Param("user_id")String user_id, @Param("name")String name, + @Param("imgurl")String imgurl, @Param("inOrOut")int inOrOut, @Param("time")String time, + @Param("cardNum")String cardNum); } diff --git a/cloud/dahua/src/main/resources/application.yaml b/cloud/dahua/src/main/resources/application.yaml index d6f1504..88ca86c 100644 --- a/cloud/dahua/src/main/resources/application.yaml +++ b/cloud/dahua/src/main/resources/application.yaml @@ -54,6 +54,6 @@ mybatis: config-location: classpath:mybatis-config.xml -haikangpic: E:\wwwhtdocs\HFface\FaceLogs\ +#haikangpic: E:\wwwhtdocs\HFface\FaceLogs\ -haikangfaceurl: http://60.190.202.57:8899 +#haikangfaceurl: http://60.190.202.57:8899 diff --git a/cloud/file/文件.xls b/cloud/file/文件.xls deleted file mode 100644 index 663a2f2..0000000 Binary files a/cloud/file/文件.xls and /dev/null differ diff --git a/cloud/haikang/src/main/java/com/sincere/haikang/CMSServer.java b/cloud/haikang/src/main/java/com/sincere/haikang/CMSServer.java index 258351e..fb99e38 100644 --- a/cloud/haikang/src/main/java/com/sincere/haikang/CMSServer.java +++ b/cloud/haikang/src/main/java/com/sincere/haikang/CMSServer.java @@ -240,7 +240,6 @@ public class CMSServer implements ApplicationRunner { } else { HCEHomeCMS.NET_EHOME_XML_CFG struXMLCfg = new HCEHomeCMS.NET_EHOME_XML_CFG(); - HCEHomeCMS.NET_EHOME_XML_REMOTE_CTRL_PARAM struRemoteCtrl = new HCEHomeCMS.NET_EHOME_XML_REMOTE_CTRL_PARAM(); HCEHomeCMS.NET_DVR_STRING_POINTER stringRequestCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); stringRequestCard.read(); String strRequestCard = "SETDEVICECONFIG"; @@ -352,6 +351,66 @@ public class CMSServer implements ApplicationRunner { } /** + * 获取指纹信息 + */ + public void getFingerPrint(String clint_id, String cardNo){ + HCEHomeCMS.NET_EHOME_XML_CFG struXMLCard = new HCEHomeCMS.NET_EHOME_XML_CFG(); + + HCEHomeCMS.NET_DVR_STRING_POINTER stringRequestCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); + stringRequestCard.read(); + String strRequestCard = "GETDEVICECONFIG"; + stringRequestCard.byString = strRequestCard.getBytes(); + stringRequestCard.write(); + + struXMLCard.pCmdBuf = stringRequestCard.getPointer(); + struXMLCard.dwCmdLen = stringRequestCard.byString.length; + struXMLCard.write(); + + HCEHomeCMS.NET_DVR_STRING_POINTER struConfigXMLCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); + struConfigXMLCard.read(); + String strConfigXMLCard = "\n" + + "GetFingerPrint\n" + + ""+cardNo+"\n" + + "1,2,3,4,5,6,7,8,9,10\n" + + "1\n" + + "0\n" + + ""; + struConfigXMLCard.byString = strConfigXMLCard.getBytes(); + struConfigXMLCard.write(); + + struXMLCard.pInBuf = struConfigXMLCard.getPointer(); + struXMLCard.dwInSize = struConfigXMLCard.byString.length; + struXMLCard.dwRecvTimeOut = 5000; + struXMLCard.dwSendTimeOut = 5000; + struXMLCard.write(); + + HCEHomeCMS.NET_DVR_STRING_POINTER stringOutCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); + stringOutCard.write(); + struXMLCard.pOutBuf = stringOutCard.getPointer(); + struXMLCard.dwOutSize = stringOutCard.size(); + struXMLCard.write(); + + HCEHomeCMS.NET_DVR_STRING_POINTER stringStatusCard = new HCEHomeCMS.NET_DVR_STRING_POINTER(); + stringStatusCard.write(); + struXMLCard.pStatusBuf = stringStatusCard.getPointer(); + struXMLCard.dwStatusSize = stringStatusCard.size(); + struXMLCard.write(); + + int i = struXMLCard.size(); + if (!hCEhomeCMS.NET_ECMS_XMLConfig(deviceAndLoginIdMap.get(clint_id), struXMLCard, struXMLCard.size())) { + int iErr = hCEhomeCMS.NET_ECMS_GetLastError(); + System.err.println("获取指纹信息,错误号:" + iErr+"card:"+cardNo); + } else { + stringOutCard.read(); + try { + System.out.println("获取指纹信息成功:"+new String(stringOutCard.byString,"utf-8").trim()); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } + + /** * 删除指纹机信息 * @param clint_id * @param cardNo @@ -496,7 +555,7 @@ public class CMSServer implements ApplicationRunner { if (cardNo != null && cardNo.length() > 0) { if (cardNo.length() >= 10) { FileUtils.getInstance().writeLogs("学生id异常:" + deviceID + " 卡号:" + cardNo+" minorType:"+minorType, FileUtils.qiandaoErr); - return false; + return true; } cardNo = userDao.getStudent_Num(cardNo); @@ -555,28 +614,4 @@ public class CMSServer implements ApplicationRunner { } } - /** - * 卡号两两倒置 - * - * @param cardDex - * @return - */ - private String cardNo(String cardDex) { - - String cardR = ""; - - int length = cardDex.length(); - if (length != 8) { - System.out.println("卡号格式不正确:" + cardDex); - return cardDex; - } - while (length > 0) { - length -= 2; - cardR += cardDex.substring(length, length + 2); - } - -// return Long.parseLong(cardR, 16) + ""; - return cardR; - - } } diff --git a/cloud/haikang/src/main/java/com/sincere/haikang/async/SendUserAsync.java b/cloud/haikang/src/main/java/com/sincere/haikang/async/SendUserAsync.java index 2a6354a..ed952a5 100644 --- a/cloud/haikang/src/main/java/com/sincere/haikang/async/SendUserAsync.java +++ b/cloud/haikang/src/main/java/com/sincere/haikang/async/SendUserAsync.java @@ -94,6 +94,12 @@ public class SendUserAsync { } @Async("taskExecutor") + public void getFingerPrint(String cardNo,String clint_id){ + + cmsServer.getFingerPrint(clint_id,cardNo); + } + + @Async("taskExecutor") public void sendStuToHaiKang(List studentBeans, int type) { try { diff --git a/cloud/haikang/src/main/java/com/sincere/haikang/control/UserControl.java b/cloud/haikang/src/main/java/com/sincere/haikang/control/UserControl.java index d7baa06..057e463 100644 --- a/cloud/haikang/src/main/java/com/sincere/haikang/control/UserControl.java +++ b/cloud/haikang/src/main/java/com/sincere/haikang/control/UserControl.java @@ -48,6 +48,17 @@ public class UserControl { } + @RequestMapping(value = "getFingerPrint",method = RequestMethod.GET) + public boolean getFingerPrint(@RequestParam("card")String card,@RequestParam("clint_id")String clint_id){ + sendUserAsync.getFingerPrint(card,clint_id); + return true; + + } + + + + + // @RequestMapping(value = "uploadImg", method= RequestMethod.GET) // public String uploadImg(@RequestParam("filePath")String filePath){ // return cmsServer.jbtnUploadActionPerformed(filePath); diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/admindao/ZuoyeAdminDao.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/admindao/ZuoyeAdminDao.java index 6da7bdb..f3923ae 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/admindao/ZuoyeAdminDao.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/admindao/ZuoyeAdminDao.java @@ -1,10 +1,11 @@ package com.sincere.haikangface.admindao; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; +import com.sincere.haikangface.bean.homework.QuestionBean; +import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; +import java.util.List; + @Mapper @Repository public interface ZuoyeAdminDao { @@ -19,5 +20,30 @@ public interface ZuoyeAdminDao { @Select("select Id from ZY_YYGrade where name like #{gradeId}") String getGradeId(@Param("gradeId") String gradeId); + @Insert("insert into ZY_YYQuestion (Question, Qtype, Answer, CorrectAnswer, Analysis, State, Intime, StemId, ExamineFlag, SubjectId, SuggestionTime, DifficulteId, ChapterId, GradeId, SourceId, QuestionSource, AutomaticCorrection)" + + " values (#{Question},#{Qtype},#{Answer},#{CorrectAnswer},#{Analysis},#{State},#{Intime},#{StemId},#{ExamineFlag},#{SubjectId},#{SuggestionTime},#{DifficulteId},#{ChapterId},#{GradeId},#{SourceId},#{QuestionSource},#{AutomaticCorrection})") + int addQuestion(@Param("Question") String Question, @Param("Qtype") String Qtype, @Param("Answer") String Answer, @Param("CorrectAnswer") String CorrectAnswer, @Param("Analysis") String Analysis, @Param("State") String State + , @Param("Intime") String Intime, @Param("StemId") String StemId, @Param("ExamineFlag") String ExamineFlag, @Param("SubjectId") String SubjectId, @Param("SuggestionTime") String SuggestionTime, @Param("DifficulteId") String DifficulteId + , @Param("ChapterId") String ChapterId, @Param("GradeId") String GradeId, @Param("SourceId") String SourceId, @Param("QuestionSource") String QuestionSource, @Param("AutomaticCorrection") String AutomaticCorrection); + + @Insert("insert into ZY_YYQuestionStem values(#{QuestionStem},#{State},#{Intime})") + int addQuestionStem(@Param("QuestionStem") String QuestionStem, @Param("State") String State, @Param("Intime") String Intime); + + @Select("select Top(1) ID from ZY_YYQuestionStem order by Intime desc ") + int getStemId(); + + @Update("update ZY_YYQuestion set StemId = #{StemId} where ID = #{ID}") + void updateQuestion(@Param("StemId") long StemId, @Param("ID")long ID); + + @Select("select top (961)ID\n" + + "from ZY_YYQuestionStem order by ID desc") + List getStemIds(); + + @Select("select Top(961)ID\n" + + "from ZY_YYQuestion order by ID desc ") + List getQueIds(); + @Insert("insert into ZY_YYQuestionAndKnowledg (QuestionId, KnowledgId, IsTest, Status)\n" + + "values (#{QuestionId},#{KnowledgId},#{IsTest},#{Status})") + void addYYQuestionAndKnowledg(@Param("QuestionId")long QuestionId,@Param("KnowledgId")long KnowledgId,@Param("IsTest")long IsTest,@Param("Status")long Status ); } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/HelpControl.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/HelpControl.java new file mode 100644 index 0000000..d95c78c --- /dev/null +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/HelpControl.java @@ -0,0 +1,113 @@ +package com.sincere.haikangface.control; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@RestController("/help/") +@Api(tags = "辅助工具") +@RequestMapping("/help/*") +public class HelpControl { + + + @RequestMapping(value = "createFile", method = RequestMethod.GET) + @ApiOperation(value = "生成文件") + @ApiImplicitParams({@ApiImplicitParam(name = "file", value = "根目录")}) + public String createFile(@RequestParam("file") String file) { +// System.out.println("count:" + (count++)); + + //第一步,创建一个workbook对应一个excel文件 + HSSFWorkbook workbook = new HSSFWorkbook(); + + File file1 = new File(file); + + File[] files = file1.listFiles(); + + List list = new ArrayList<>(); + + for (int i = 0; i < files.length; i++) { + File file2 = files[i]; + + if (file2.isDirectory()) { + + File[] file3 = file2.listFiles(); + for (int j = 0; j < file3.length; j++) { + File file4 = file3[j]; + String fileName = file4.getName(); + String fileDirName = file2.getName(); + list.add(fileDirName+","+fileName); + } + + }else if (file2.isFile()){ + String fileName = file2.getName() ; + String fileDirName = file1.getName(); + list.add(fileDirName+","+fileName); + } + + } + + + return writeToExcel(workbook,"文件",list).getAbsolutePath(); + } + + + private File writeToExcel(HSSFWorkbook workbook, String sheetName, List values) { + //第二部,在workbook中创建一个sheet对应excel中的sheet + HSSFSheet sheet = workbook.createSheet(sheetName); + //第三部,在sheet表中添加表头第0行,老版本的poi对sheet的行列有限制 + HSSFRow row = sheet.createRow(0); + //第四步,创建单元格,设置表头 + HSSFCell cell = null; + for (int i = 0; i < 2; i++) { + cell = row.createCell(i); + if (i == 0) + cell.setCellValue("目录名称"); + else if (i==1) + cell.setCellValue("文件名称"); + } + + //第五步,写入数据 + for (int i = 0; i < values.size(); i++) { + + HSSFRow row1 = sheet.createRow(i + 1); + String value = values.get(i); + + row1.createCell(0).setCellValue(value.split(",")[0]); + row1.createCell(1).setCellValue(value.split(",")[1]); + } + + //将文件保存到指定的位置 + try { + File file = new File("./file/"); + if (!file.exists()) file.mkdirs(); + + File file1 = new File(file.getAbsolutePath(), sheetName + ".xls"); + if (!file1.exists()) file1.createNewFile(); + FileOutputStream fos = new FileOutputStream(file1); + workbook.write(fos); + System.out.println("写入成功"); + fos.close(); + return file1; + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java index d7d3ddb..309c967 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java @@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import sun.rmi.runtime.Log; import java.io.*; import java.math.BigInteger; @@ -53,22 +54,19 @@ public class UserControl { @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { try { -// System.out.println("设备编号:" + deviceId); FileUtils.getInstance().writeLogs("filePath:" + filePath + " card:" + card + " name:" + name + " deviceId:" + deviceId, FileUtils.sendUserInfo); long time = System.currentTimeMillis(); - if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); +// if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); if (new File(filePath.trim()).exists()) { String targetPath = FileUtils.picPathComp + new File(filePath).getName(); try { -// System.out.println("targetPath:" + targetPath + " targetPath:" + new File(targetPath).exists()); -// System.out.println("exit:" + new File(targetPath).exists() + " targetPath:" + targetPath); int isPiliang = 0;//0:批量,1:单张 if (filePath.contains("face17e50")) {//批量发送 isPiliang = 0; } else {//单图发送 isPiliang = 1; } - sendUserAsync.sendStuToHaiKang(filePath, targetPath, new BigInteger(getCard(card), 16).toString(), startTime, endTime, validTimeEnabled, name, deviceId, userType, isPiliang); + sendUserAsync.sendStuToHaiKang(filePath, targetPath, Long.parseLong(getCard(card), 16)+"", startTime, endTime, validTimeEnabled, name, deviceId, userType, isPiliang); System.out.println("time:" + (System.currentTimeMillis() - time) / 1000); @@ -79,7 +77,7 @@ public class UserControl { } else { if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils(); - sendRecoderUtils.sendFail(sendRecordDao, new BigInteger(getCard(card), 16).toString(), filePath, deviceId, userDao, "文件不存在", userType); + sendRecoderUtils.sendFail(sendRecordDao, Long.parseLong(getCard(card), 16)+"", filePath, deviceId, userDao, "文件不存在", userType); System.out.println("文件不存在:" + filePath); } } catch (Exception e) { diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java index 936568f..a051196 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java @@ -185,4 +185,10 @@ public interface UserDao { @Select("select clint_id from SZ_AttendanceDto where school_id = #{schoolId} and clint_type=18") List getDeviceIdsWidthSchoolId(@Param("schoolId") int schoolId); + + + @Select("select StudentId from SS_RoomNumber where Pid in (select id\n" + + " from SS_Room\n" + + " where SchoolId = 479 and SS_Room.Pid =10284 )") + List getStudentIdWithRoom(); } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/ZuoYeDao.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/ZuoYeDao.java index fc68db8..71823c0 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/ZuoYeDao.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/ZuoYeDao.java @@ -70,7 +70,6 @@ public interface ZuoYeDao { @Insert("insert into TK_QuestionStem values(#{QuestionStem},#{State},#{Intime})") int addQuestionStem(@Param("QuestionStem") String QuestionStem, @Param("State") String State, @Param("Intime") String Intime); - @Select("select Top(1) ID from TK_QuestionStem order by Intime desc ") int getStemId(); @@ -86,4 +85,10 @@ public interface ZuoYeDao { @Select("select IsCorrect from ZY_StudentAnswer where ID = #{ID}") int getIsCorrect(@Param("ID") String id); + + @Select("select *\n" + + "from TK_Question where Intime>'2019-01-01' and Qtype = 1 and ID in (select QuestionId from TK_QuestionAndKnowledg where KnowledgId>94569) order by Intime desc") + List getQuestionsRecent(); + + } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/SendRecoderUtils.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/SendRecoderUtils.java index 7a329af..abd0fa0 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/SendRecoderUtils.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/SendRecoderUtils.java @@ -24,8 +24,9 @@ public class SendRecoderUtils { */ public void sendSuccess(SendRecordDao sendRecordDao, String card, String faceUrl, String deviceId, UserDao userDao, String userType) { - BigInteger bigInteger = new BigInteger(card); - String resultCard = getCard(String.format("%08x", bigInteger)).toUpperCase(); +// BigInteger bigInteger = new BigInteger(card); + long lon = Long.parseLong(card); + String resultCard = getCard(String.format("%08x", lon)).toUpperCase(); StudentBean studentBean = null; String customerId = ""; switch (userType) { @@ -81,8 +82,9 @@ public class SendRecoderUtils { * @param userDao */ public void sendFail(SendRecordDao sendRecordDao, String card, String faceUrl, String deviceId, UserDao userDao, String content, String userType) { - BigInteger bigInteger = new BigInteger(card); - String resultCard = getCard(String.format("%08x", bigInteger)).toUpperCase(); +// BigInteger bigInteger = new BigInteger(card); + long lon = Long.parseLong(card); + String resultCard = getCard(String.format("%08x", lon)).toUpperCase(); StudentBean studentBean = null; String customerId = ""; switch (userType) { diff --git a/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java b/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java index c2f412f..8669aa6 100644 --- a/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java +++ b/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java @@ -6,11 +6,14 @@ import com.drew.metadata.Directory; import com.drew.metadata.Metadata; import com.drew.metadata.MetadataException; import com.drew.metadata.exif.ExifDirectory; +import com.sincere.haikangface.admindao.ZuoyeAdminDao; import com.sincere.haikangface.bean.*; +import com.sincere.haikangface.bean.homework.QuestionBean; import com.sincere.haikangface.bean.xiaoan.AttendanceRecordsSS; import com.sincere.haikangface.bean.xiaoan.CreditCardRecordsSS; import com.sincere.haikangface.dao.DeviceDao; import com.sincere.haikangface.dao.UserDao; +import com.sincere.haikangface.dao.ZuoYeDao; import com.sincere.haikangface.xiananDao.SendRecordDao; import org.bouncycastle.asn1.cms.MetaData; import org.hibernate.validator.constraints.LuhnCheck; @@ -82,9 +85,9 @@ public class HaikangfaceApplicationTests { @Test public void send() { - /*RestTemplate restTemplate = new RestTemplate(); + /* RestTemplate restTemplate = new RestTemplate(); //失败人脸补发 - List sendRecordBeanList = sendRecordDao.getSenFail("562",2); + List sendRecordBeanList = sendRecordDao.getSenFail("1066",2); int idnex = 0; for (int i = 0; i < sendRecordBeanList.size(); i++) { SendRecordBean sendRecordBean = sendRecordBeanList.get(i); @@ -92,11 +95,11 @@ public class HaikangfaceApplicationTests { ,sendRecordBean.getNum(),sendRecordBean.getDeviceID(),"2023-10-01 10:00:00",sendRecordBean.getImgPath(),sendRecordBean.getName(),"2","1","2019-10-01 10:00:00"); String result1 = restTemplate.getForObject(url, String.class); System.out.println("下发人脸:" + result1+" idnex:"+idnex++); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } +// try { +// Thread.sleep(2000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } }*/ @@ -280,158 +283,34 @@ public class HaikangfaceApplicationTests { }*/ } - @Test - public void fileRes() { - - - /*List stringList = sendRecordDao.getAllARecords(); - for (int i = 0; i < stringList.size(); i++) { - - List stus = sendRecordDao.getARecords(stringList.get(i)); - if (stus.size()>0){ - AttendanceRecordsSS attendanceRecordsSS = stus.get(0); - - sendRecordDao.deleteARecords(attendanceRecordsSS.getCustomerId(),attendanceRecordsSS.getSystime()); - - } - - }*/ - - - - - /* List creditCardRecordsSSES = sendRecordDao.getCardRecordss(); - List customerIds = new ArrayList<>(); - for (int i = 0; i < creditCardRecordsSSES.size(); i++) { - CreditCardRecordsSS creditCardRecordsSS = creditCardRecordsSSES.get(i); - if (!customerIds.contains(creditCardRecordsSS.getCustomerId())) { - customerIds.add(creditCardRecordsSS.getCustomerId()); - System.out.println("creditCardRecordsSS:" + creditCardRecordsSS.toString()); - String classId = userDao.getClassName(creditCardRecordsSS.getCustomerId()); - System.out.println("classId:" + classId); - int result = sendRecordDao.addAttenRecodrds(creditCardRecordsSS.getUser_id(), creditCardRecordsSS.getSchool_id(), - creditCardRecordsSS.getCustomerId(), creditCardRecordsSS.getUsertype(), creditCardRecordsSS.getCard_num(), - creditCardRecordsSS.getCard_type(), creditCardRecordsSS.getOutof(), creditCardRecordsSS.getIntime(), - creditCardRecordsSS.getCid(), creditCardRecordsSS.getFunc_no(), creditCardRecordsSS.getHead_image(), - classId, "", creditCardRecordsSS.getAttendance_id(), creditCardRecordsSS.getName(), creditCardRecordsSS.getMobile(), creditCardRecordsSS.getClass_name(), - creditCardRecordsSS.getSex(), creditCardRecordsSS.getStudent_type(), creditCardRecordsSS.getSystime()); - System.out.println("result:" + result); - } - - }*/ - /*File file = new File("C:\\TaoHandong\\copy\\21_指纹签到.txt"); - - try { - BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); - - String content = null; - Set strings = new HashSet<>();//存放studentid - while ((content = bufferedReader.readLine()) != null) { - if (content.contains("0x26")) { - strings.add(content.split("cardNo:")[1]); - } - } - System.out.println( "指纹签到数据:"+strings.size()); - - String studentId = ""; - - //获取全部住校生 - List studentBeanList = userDao.getAllStuWithSchoolId("479"); - - for (int i = 0; i < studentBeanList.size(); i++) { - StudentBean studentBean = studentBeanList.get(i); - - if (!strings.contains(studentBean.getStudent_id())) { - studentId += "'" + studentBean.getStudent_id() + "',"; - } - - } -// System.out.println("studentId:"+studentId); - - - File fileQD = new File("C:\\TaoHandong\\copy\\签到人员.txt"); + @Autowired + ZuoYeDao zuoYeDao; - BufferedReader bufferedReaderQD = new BufferedReader(new FileReader(fileQD)); - String contentQD = null; - Set stringsQD = new HashSet<>();//存放studentid - while ((contentQD = bufferedReaderQD.readLine()) != null) { - List studentids = userDao.getStudentIdWidthName(contentQD.trim(), "479"); - for (int i = 0; i < studentids.size(); i++) { - stringsQD.add(studentids.get(i)); - } - } - System.out.println("stringsQD:" + stringsQD.size()); - String resultStuid=""; - Iterator iterator = stringsQD.iterator(); - while (iterator.hasNext()) { - String studentId11 = (String) iterator.next(); - Iterator iterator1 = strings.iterator(); - boolean isHas = false; - while (iterator1.hasNext()) { - String stuId = (String) iterator1.next(); - if (studentId11.equals(stuId)) { - isHas = true; - } - } - if (!isHas) resultStuid += "'" + studentId11 + "',"; - } + @Autowired + ZuoyeAdminDao zuoyeAdminDao; - System.out.println("resultStuid:" + resultStuid); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + @Test + public void fileRes() { + List questionBeans = zuoYeDao.getQuestionsRecent(); + /* List questionBeans = zuoYeDao.getQuestionsRecent(); + String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + for (QuestionBean ques : + questionBeans) { + zuoyeAdminDao.addQuestionStem("请回答下列问题", "1", dateTime); + int stemId = zuoyeAdminDao.getStemId(); + String intime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + zuoyeAdminDao.addQuestion(ques.getQuestion(),ques.getQtype(),ques.getAnswer(),ques.getCorrectAnswer(),ques.getAnalysis(), + ques.getState(),intime,stemId+"",ques.getExamineFlag(),ques.getSubjectId(),"10","1",ques.getChapterId(),ques.getGradeId()+"","1","","1"); }*/ +List queIds = zuoyeAdminDao.getQueIds(); -// List fileBeans = userDao.getFileRes(); - - /* List fileBeanList = userDao.getFIlesReses(); - - List userIds = userDao.getUserids(); - - for (int i = 0; i < fileBeanList.size(); i++) { - FileBean fileBean = fileBeanList.get(i); - for (int j = 0; j < userIds.size(); j++) { - String userId= userIds.get(j); - String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); - userDao.addRelation(fileBean.getId(),time,userId); + for (int i = queIds.size()-1; i >=0 ; i--) { + zuoyeAdminDao.addYYQuestionAndKnowledg(queIds.get(i), Long.parseLong(questionBeans.get(questionBeans.size()-1-i).getKnowledgeId()),0,1); } - }*/ - - -// System.out.println("fileBeans:"+fileBeans.toString()); -/*int index = 744; - for (int i = index; i - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - -- libgit2 0.21.0