diff --git a/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask2.java b/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask2.java index de48636..b3ea26b 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask2.java +++ b/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask2.java @@ -1,6 +1,7 @@ package com.example.dahua.async; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.example.dahua.MyTask; import com.example.dahua.bean.*; import com.example.dahua.dao.UserDao; @@ -116,7 +117,7 @@ public class SendUserInfoTask2 { */ pushCardAndFace(file, userInfoBean, deviceList,sendRecordBean.getUserType()+"",sendRecordBean.getFailType()); } catch (Exception e) { - log.error("下发失败"); + log.error("下发失败:{}",e); return false; } return false; @@ -150,7 +151,7 @@ public class SendUserInfoTask2 { * @param failType */ private synchronized void pushCardAndFace(String picSrc, UserInfoBean userInfoBean,List deviceList,String userType, int failType) { - log.info("下发人脸设备总数,size: "+ deviceList.size()); + log.info("下发人脸设备总数,size:{},用户信息:{}",deviceList.size(), JSONObject.toJSONString(userInfoBean)); String facePath = compressPic(picSrc,userInfoBean.getStudentcode()); if(StringUtils.isEmpty(facePath)){ log.warn("压缩后图片路径为空!"); diff --git a/cloud/dahua/src/main/java/com/example/dahua/service/imp/BaseService.java b/cloud/dahua/src/main/java/com/example/dahua/service/imp/BaseService.java index e4e4f14..acef6fb 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/service/imp/BaseService.java +++ b/cloud/dahua/src/main/java/com/example/dahua/service/imp/BaseService.java @@ -216,7 +216,7 @@ public class BaseService { } public List getDeviceList(String deviceIds,Integer schoolId){ - if(StringUtils.isEmpty(deviceIds)) return Arrays.asList(deviceIds.split(",")); + if(!StringUtils.isEmpty(deviceIds)) return Arrays.asList(deviceIds.split(",")); return userDao.selectDeviceBySchoolId(schoolId); } diff --git a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java index a1d5a3c..e076c05 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java +++ b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java @@ -70,7 +70,7 @@ public class UserOperateServiceImpl implements UserOperateService { if(Objects.equals(faceBean.getUserType(),2)) studentBeans = baseService.getStudentByClassId(faceBean); else studentBeans = baseService.getTeacherList(faceBean.getSchoolId()); if(CollectionUtils.isEmpty(studentBeans)) return; - log.info("统计共有下发用户数量:{}",studentBeans.size()); + log.info("统计共有下发用户数量:{},下发设备数量:{}",studentBeans.size(),deviceList.size()); //下发人脸 sendFace(studentBeans,deviceList, faceBean.getSchoolId(), faceBean.getUserType()); } @@ -80,7 +80,7 @@ public class UserOperateServiceImpl implements UserOperateService { List deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId()); //根据类型获取下发用户信息 List studentBeans = baseService.getStudentByRoomId(faceBean.getSchoolId(),faceBean.getRoomId()); - log.info("统计共有下发用户数量:{}",studentBeans.size()); + log.info("统计共有下发用户数量:{},下发设备数量:{}",studentBeans.size(),deviceList.size()); //下發人臉 sendFace(studentBeans,deviceList, faceBean.getSchoolId(),faceBean.getUserType()); } diff --git a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java index 2787fa3..fcbfbc9 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java +++ b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java @@ -81,6 +81,7 @@ public class UserServiceImp implements UserService { userInfoBean.setUser_id(teacher.getUser_id()); userInfoBean.setStudentcode(teacher.getNum()); userInfoBean.setStudent_id(teacher.getTeacher_id()); + userInfoBean.setSchool_id(schoolId+""); } } //下发任务 diff --git a/cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java b/cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java index 96ef26d..a9cf37c 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java +++ b/cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java @@ -47,7 +47,7 @@ public class HttpUtils { multivaluedMap.add("studentCode", studentCode); multivaluedMap.add("userType", userType); if(!StringUtils.isEmpty(deviceId)){ - multivaluedMap.add("deviceIds", deviceId); + multivaluedMap.add("deviceId", deviceId); } httpEntity = new HttpEntity<>(multivaluedMap, headers); responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); 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 b9f711d..d7a58ab 100644 --- a/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java +++ b/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java @@ -1,269 +1,269 @@ -package com.sincere.haikangface; - -import com.alibaba.fastjson.JSONObject; -import com.drew.imaging.jpeg.JpegMetadataReader; -import com.drew.imaging.jpeg.JpegProcessingException; -import com.drew.metadata.Directory; -import com.drew.metadata.Metadata; -import com.drew.metadata.MetadataException; -import com.drew.metadata.exif.ExifDirectory; -import com.sincere.haikangface.admindao.ZuoyeAdminDao; -import com.sincere.haikangface.bean.*; -import com.sincere.haikangface.bean.homework.QuestionBean; -import com.sincere.haikangface.bean.test.SaveStudentBak; -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.service.impl.BaseService; -import com.sincere.haikangface.utils.ApiUtil; -import com.sincere.haikangface.utils.DateUtils; -import com.sincere.haikangface.xiananDao.SendRecordDao; -import org.apache.commons.lang3.RandomStringUtils; -import org.bouncycastle.asn1.cms.MetaData; -import org.hibernate.validator.constraints.LuhnCheck; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.core.io.FileSystemResource; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.CollectionUtils; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.util.StringUtils; -import org.springframework.web.client.RestTemplate; - -import javax.imageio.stream.FileImageInputStream; -import javax.imageio.stream.FileImageOutputStream; -import javax.ws.rs.core.MultivaluedMap; -import java.io.*; -import java.math.BigInteger; -import java.text.SimpleDateFormat; -import java.util.*; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class HaikangfaceApplicationTests { - - @Autowired - UserDao userDao; - - @Autowired - DeviceDao deviceDao; - - @Autowired - SendRecordDao sendRecordDao; - - @Autowired - ZuoYeDao zuoYeDao; - - @Autowired - ZuoyeAdminDao zuoyeAdminDao; - - @Autowired - BaseService baseService; - - @Test - public void sync() { -// String deviceIds = "338652415671,694642005671,694642555671,338652515671,338653105671,338652895671,ytj687425415671,ytj694642105671,694642135671,ytj694642375671"; -// String deviceIds = "687425135671,ytj687425345671,ytj687425395671,ytj687425155671,687425355671,687425225671,687425265671,740456495671,687425325671,694642215671"; - //陆埠 - String deviceIds = "840153165671,840153205671,840153485671,840153965671,840153325671,840153835671,840154005671,840153105671"; - //艺术 -// String deviceIds = "567176463869,567176463898,567176463903,567176463892"; - Integer schoolId = 1066; - baseService.clearStudent(schoolId,deviceIds); - baseService.clearStudent2(schoolId); - } - - @Test - public void checkFaceSend() { - String deviceIds = "694642005671,694642215671,687425355671,687425325671,338652895671,687425135671,ytj694642375671,338652415671,687425265671,ytj687425345671,338652515671,694642555671,ytj694642105671,338653105671,ytj687425415671,ytj687425155671,740456495671,694642135671,ytj687425395671,687425225671"; - //下发设备集合 - List deviceList= new ArrayList<>(Arrays.asList(deviceIds.split(","))); - List studentBeans = userDao.getStudentBySchoolId(865); - studentBeans.stream().distinct().forEach(studentBean -> { - String name = studentBean.getName(); - String userId = studentBean.getUser_id(); - String cardNum = studentBean.getStudent_num(); - String className = studentBean.getClass_name(); - for(String s : deviceList){ - List sendRecordBeans = sendRecordDao.getRecordIsExit(s,cardNum,userId); - if(CollectionUtils.isEmpty(sendRecordBeans)){ - SaveStudentBak saveStudentBak = new SaveStudentBak(); - saveStudentBak.setCardNum(cardNum); - saveStudentBak.setClientId(s); - saveStudentBak.setUserId(userId); - saveStudentBak.setName(name); - saveStudentBak.setClassName(className); - saveStudentBak.setStatus(2); -// userDao.insertStudent(saveStudentBak); - } - } - }); - } - - public String splicingZero(String str, int totalLenght) { - int strLenght = str.length(); - String strReturn = str; - for (int i = 0; i < totalLenght - strLenght; i++) { - strReturn = "0" + strReturn; - } - return strReturn; - } - - - @Test - public void delete() { - Integer schoolId =27; - Integer roomId = 11748; - Integer type = 7; - Integer outof = 1; - Integer size = 66; - String startTime= "2021-01-11 00:00:00"; - String endTime ="2021-01-11 23:59:59"; - List studentIds = userDao.queryStudentIdList(schoolId,roomId); - if(!CollectionUtils.isEmpty(studentIds)){ - for(int i=0;i<=studentIds.size();i++){ - if(i == size){ - return; - } - StudentBean userInfoBean = userDao.getStudentWithid(studentIds.get(i)); - if(userInfoBean!=null){ - String cardNum = userInfoBean.getStudent_num(); - System.out.println(i); - sendRecordDao.deleteSS(schoolId,cardNum,type,outof,startTime,endTime); - } - } - } - } - - @Test - public void delete2() { - Integer schoolId =27; - Integer roomId = 11748; - Integer type = 12; - Integer outof = 0; - Integer size =62; - String startTime= "2021-01-22 00:00:00"; - String endTime ="2021-01-22 23:59:59"; - List studentIds = userDao.queryStudentIdList(schoolId,roomId); - if(!CollectionUtils.isEmpty(studentIds)){ - for(int i=0;i<=studentIds.size();i++){ - if(i == size){ - return; - } - StudentBean userInfoBean = userDao.getStudentWithid(studentIds.get(i)); - if(userInfoBean!=null){ - String cardNum = userInfoBean.getStudent_num(); - System.out.println(i); - sendRecordDao.deleteSS(schoolId,cardNum,type,outof,startTime,endTime); - } - } - } - } - - @Test - public void test() { - List students = userDao.getStudentBySchoolId(12); - int i = 0; - for(StudentBean studentBean : students){ - String time = DateUtils.date2String(new Date(),"yyyyMMddHHmm"); - String randomString = RandomStringUtils.randomNumeric(4); - String studentCode = "YX"+time+randomString+".png"; - String photo = studentBean.getPhoto(); - System.out.println("源文件:" + photo); - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School12\\Student"; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School12\\Student"; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - String filePath =""; - String filePath2 =""; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath = path_3 + afterStr; - filePath2 = path_3 + studentCode; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - filePath2 = path_2 + "\\" + studentCode; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; - filePath2 = path_1 + "\\" + studentCode; - } - if(filePath.indexOf("?v=")!=-1){ - filePath = filePath.split("\\?")[0]; - } - File file = new File(filePath.trim());//图片 - if (file.exists()) { - //原始文件路径 - String srcPath = file.getAbsolutePath(); - System.out.println("文件名:" + fileName + ", 学籍号:" + fileName.split("\\.")[0]); - //复制文件 - copy(srcPath,filePath2); - String savePath = "http://campus.myjxt.com//" + filePath2; - studentBean.setPhoto(savePath); - userDao.updateUser(studentBean.getUser_id(), savePath); - file.delete(); - i++; - } - if(i==1){ - System.out.println(filePath); - return; - } - } - } - - public static void copy(String srcPathStr, String desPathStr) { - //获取源文件的名称 - try { - FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象 - FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象 - byte datas[] = new byte[1024*8];//创建搬运工具 - int len = 0;//创建长度 - while((len = fis.read(datas))!=-1)//循环读取数据 - { - fos.write(datas,0,len); - } - fis.close();//释放资源 - fis.close();//释放资源 - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - - @Test - public void send2() { - try { - String api = "http://yixiao.198.hmkj.com.cn/index.php/Attend/send"; - RestTemplate restTemplate = new RestTemplate(); - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("name", "测试"); - map.add("xuehao", "1122"); - map.add("time", "2022-02-10 09:09:00"); - map.add("state", 1); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - HttpEntity> param = new HttpEntity<>(map, headers); - ResponseEntity response = restTemplate.postForEntity(api, param, String.class); - String body = response.getBody(); - System.out.println(body); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("考勤失败"); - } - } -} +//package com.sincere.haikangface; +// +//import com.alibaba.fastjson.JSONObject; +//import com.drew.imaging.jpeg.JpegMetadataReader; +//import com.drew.imaging.jpeg.JpegProcessingException; +//import com.drew.metadata.Directory; +//import com.drew.metadata.Metadata; +//import com.drew.metadata.MetadataException; +//import com.drew.metadata.exif.ExifDirectory; +//import com.sincere.haikangface.admindao.ZuoyeAdminDao; +//import com.sincere.haikangface.bean.*; +//import com.sincere.haikangface.bean.homework.QuestionBean; +//import com.sincere.haikangface.bean.test.SaveStudentBak; +//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.service.impl.BaseService; +//import com.sincere.haikangface.utils.ApiUtil; +//import com.sincere.haikangface.utils.DateUtils; +//import com.sincere.haikangface.xiananDao.SendRecordDao; +//import org.apache.commons.lang3.RandomStringUtils; +//import org.bouncycastle.asn1.cms.MetaData; +//import org.hibernate.validator.constraints.LuhnCheck; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.core.io.FileSystemResource; +//import org.springframework.http.HttpEntity; +//import org.springframework.http.HttpHeaders; +//import org.springframework.http.MediaType; +//import org.springframework.http.ResponseEntity; +//import org.springframework.test.context.junit4.SpringRunner; +//import org.springframework.util.CollectionUtils; +//import org.springframework.util.LinkedMultiValueMap; +//import org.springframework.util.MultiValueMap; +//import org.springframework.util.StringUtils; +//import org.springframework.web.client.RestTemplate; +// +//import javax.imageio.stream.FileImageInputStream; +//import javax.imageio.stream.FileImageOutputStream; +//import javax.ws.rs.core.MultivaluedMap; +//import java.io.*; +//import java.math.BigInteger; +//import java.text.SimpleDateFormat; +//import java.util.*; +// +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class HaikangfaceApplicationTests { +// +// @Autowired +// UserDao userDao; +// +// @Autowired +// DeviceDao deviceDao; +// +// @Autowired +// SendRecordDao sendRecordDao; +// +// @Autowired +// ZuoYeDao zuoYeDao; +// +// @Autowired +// ZuoyeAdminDao zuoyeAdminDao; +// +// @Autowired +// BaseService baseService; +// +// @Test +// public void sync() { +//// String deviceIds = "338652415671,694642005671,694642555671,338652515671,338653105671,338652895671,ytj687425415671,ytj694642105671,694642135671,ytj694642375671"; +//// String deviceIds = "687425135671,ytj687425345671,ytj687425395671,ytj687425155671,687425355671,687425225671,687425265671,740456495671,687425325671,694642215671"; +// //陆埠 +// String deviceIds = "840153165671,840153205671,840153485671,840153965671,840153325671,840153835671,840154005671,840153105671"; +// //艺术 +//// String deviceIds = "567176463869,567176463898,567176463903,567176463892"; +// Integer schoolId = 1066; +// baseService.clearStudent(schoolId,deviceIds); +// baseService.clearStudent2(schoolId); +// } +// +// @Test +// public void checkFaceSend() { +// String deviceIds = "694642005671,694642215671,687425355671,687425325671,338652895671,687425135671,ytj694642375671,338652415671,687425265671,ytj687425345671,338652515671,694642555671,ytj694642105671,338653105671,ytj687425415671,ytj687425155671,740456495671,694642135671,ytj687425395671,687425225671"; +// //下发设备集合 +// List deviceList= new ArrayList<>(Arrays.asList(deviceIds.split(","))); +// List studentBeans = userDao.getStudentBySchoolId(865); +// studentBeans.stream().distinct().forEach(studentBean -> { +// String name = studentBean.getName(); +// String userId = studentBean.getUser_id(); +// String cardNum = studentBean.getStudent_num(); +// String className = studentBean.getClass_name(); +// for(String s : deviceList){ +// List sendRecordBeans = sendRecordDao.getRecordIsExit(s,cardNum,userId); +// if(CollectionUtils.isEmpty(sendRecordBeans)){ +// SaveStudentBak saveStudentBak = new SaveStudentBak(); +// saveStudentBak.setCardNum(cardNum); +// saveStudentBak.setClientId(s); +// saveStudentBak.setUserId(userId); +// saveStudentBak.setName(name); +// saveStudentBak.setClassName(className); +// saveStudentBak.setStatus(2); +//// userDao.insertStudent(saveStudentBak); +// } +// } +// }); +// } +// +// public String splicingZero(String str, int totalLenght) { +// int strLenght = str.length(); +// String strReturn = str; +// for (int i = 0; i < totalLenght - strLenght; i++) { +// strReturn = "0" + strReturn; +// } +// return strReturn; +// } +// +// +// @Test +// public void delete() { +// Integer schoolId =27; +// Integer roomId = 11748; +// Integer type = 7; +// Integer outof = 1; +// Integer size = 66; +// String startTime= "2021-01-11 00:00:00"; +// String endTime ="2021-01-11 23:59:59"; +// List studentIds = userDao.queryStudentIdList(schoolId,roomId); +// if(!CollectionUtils.isEmpty(studentIds)){ +// for(int i=0;i<=studentIds.size();i++){ +// if(i == size){ +// return; +// } +// StudentBean userInfoBean = userDao.getStudentWithid(studentIds.get(i)); +// if(userInfoBean!=null){ +// String cardNum = userInfoBean.getStudent_num(); +// System.out.println(i); +// sendRecordDao.deleteSS(schoolId,cardNum,type,outof,startTime,endTime); +// } +// } +// } +// } +// +// @Test +// public void delete2() { +// Integer schoolId =27; +// Integer roomId = 11748; +// Integer type = 12; +// Integer outof = 0; +// Integer size =62; +// String startTime= "2021-01-22 00:00:00"; +// String endTime ="2021-01-22 23:59:59"; +// List studentIds = userDao.queryStudentIdList(schoolId,roomId); +// if(!CollectionUtils.isEmpty(studentIds)){ +// for(int i=0;i<=studentIds.size();i++){ +// if(i == size){ +// return; +// } +// StudentBean userInfoBean = userDao.getStudentWithid(studentIds.get(i)); +// if(userInfoBean!=null){ +// String cardNum = userInfoBean.getStudent_num(); +// System.out.println(i); +// sendRecordDao.deleteSS(schoolId,cardNum,type,outof,startTime,endTime); +// } +// } +// } +// } +// +// @Test +// public void test() { +// List students = userDao.getStudentBySchoolId(12); +// int i = 0; +// for(StudentBean studentBean : students){ +// String time = DateUtils.date2String(new Date(),"yyyyMMddHHmm"); +// String randomString = RandomStringUtils.randomNumeric(4); +// String studentCode = "YX"+time+randomString+".png"; +// String photo = studentBean.getPhoto(); +// System.out.println("源文件:" + photo); +// //以学籍号为名的文件名 +// String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); +// //100服务器人脸照绝对路径 +// //100服务器人脸照绝对路径 +// String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School12\\Student"; +// String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School12\\Student"; +// String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; +// String filePath =""; +// String filePath2 =""; +// if(photo.indexOf("f0i5l7e5")!=-1){ +// String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); +// filePath = path_3 + afterStr; +// filePath2 = path_3 + studentCode; +// } +// if(photo.indexOf("face17e5")!=-1){ +// filePath = path_2 + "\\" + fileName; +// filePath2 = path_2 + "\\" + studentCode; +// } +// if(photo.indexOf("face17e50")!=-1){ +// filePath = path_1 + "\\" + fileName; +// filePath2 = path_1 + "\\" + studentCode; +// } +// if(filePath.indexOf("?v=")!=-1){ +// filePath = filePath.split("\\?")[0]; +// } +// File file = new File(filePath.trim());//图片 +// if (file.exists()) { +// //原始文件路径 +// String srcPath = file.getAbsolutePath(); +// System.out.println("文件名:" + fileName + ", 学籍号:" + fileName.split("\\.")[0]); +// //复制文件 +// copy(srcPath,filePath2); +// String savePath = "http://campus.myjxt.com//" + filePath2; +// studentBean.setPhoto(savePath); +// userDao.updateUser(studentBean.getUser_id(), savePath); +// file.delete(); +// i++; +// } +// if(i==1){ +// System.out.println(filePath); +// return; +// } +// } +// } +// +// public static void copy(String srcPathStr, String desPathStr) { +// //获取源文件的名称 +// try { +// FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象 +// FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象 +// byte datas[] = new byte[1024*8];//创建搬运工具 +// int len = 0;//创建长度 +// while((len = fis.read(datas))!=-1)//循环读取数据 +// { +// fos.write(datas,0,len); +// } +// fis.close();//释放资源 +// fis.close();//释放资源 +// } +// catch (Exception e) +// { +// e.printStackTrace(); +// } +// } +// +// +// @Test +// public void send2() { +// try { +// String api = "http://yixiao.198.hmkj.com.cn/index.php/Attend/send"; +// RestTemplate restTemplate = new RestTemplate(); +// MultiValueMap map = new LinkedMultiValueMap<>(); +// map.add("name", "测试"); +// map.add("xuehao", "1122"); +// map.add("time", "2022-02-10 09:09:00"); +// map.add("state", 1); +// HttpHeaders headers = new HttpHeaders(); +// headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); +// HttpEntity> param = new HttpEntity<>(map, headers); +// ResponseEntity response = restTemplate.postForEntity(api, param, String.class); +// String body = response.getBody(); +// System.out.println(body); +// } catch (Exception e) { +// e.printStackTrace(); +// System.out.println("考勤失败"); +// } +// } +//} -- libgit2 0.21.0