integrated_traffic/src/main/java/com/zcloud/controller/eduApp/AppUsersCacheController.java

725 lines
32 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.zcloud.controller.eduApp;
import com.zcloud.controller.base.BaseController;
import com.zcloud.mapper.dsno3.eduStudy.StudentMapper;
import com.zcloud.service.eduArchives.ArchivesStudentService;
import com.zcloud.service.eduStudy.FaceImgLogService;
import com.zcloud.mapper.dsno3.eduSystem.BaseFactoryMapper;
import com.zcloud.service.eduSystem.UsersCacheService;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.Response;
import com.zcloud.plugins.websocketFace.FaceServerPool;
import com.zcloud.service.system.UserInfoService;
import com.zcloud.util.*;
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.java_websocket.WebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import ws.schild.jave.MultimediaInfo;
import ws.schild.jave.MultimediaObject;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
/**
* 说明app用户处理
* 作者guoyuepeng
* 官网www.qdkjchina.com
*/
@RestController
@RequestMapping("/app/user")
public class AppUsersCacheController extends BaseController {
@Resource
private UsersCacheService usersCacheService;
@Resource
private InitPageDataUtil initPageDataUtil;
@Resource
private BaseFactoryMapper baseFactoryMapper;
@Resource
private StudentMapper studentMapper;
@Resource
private Smb smb;
@Resource
private FaceImgLogService faceImgLogService;
@Autowired
private ArchivesStudentService archivesstudentService;
@Autowired
private UserInfoService userInfoService;
//@RequestMapping("/getUser")
public Response getUser() throws Exception {
Response response = Response.getResponse();
try {
PageData request = this.getPageData();
PageData info = usersCacheService.getStudentInfo(request);
response.put("info", info);
} catch (Exception e) {
e.printStackTrace();
return response.errorMessage(e.getMessage());
}
return response.OK();
}
/**
* descritpion: 临时查询用户信息方法
* 悦哥说临时使用
*
* @return
* @throws Exception
*/
@RequestMapping("/getUser")
public Response temporaryGetUser() throws Exception {
Response response = Response.getResponse();
try {
PageData request = this.getPageData();
List<PageData> info = usersCacheService.getTemporaryStudentInfo(request);
Optional<PageData> new_info = info.stream().max(Comparator.comparing(o -> DateUtil.getDate(o.getString("CREATTIME"))));
response.put("pd", new_info.orElse(null));
} catch (Exception e) {
e.printStackTrace();
return response.errorMessage(e.getMessage());
}
return response.OK();
}
@RequestMapping("/serialize")
public Response serialize() throws Exception {
Response response = Response.getResponse();
return response.OK();
}
@RequestMapping("/editUserPwd")
public Response editUserPwd() throws Exception {
Response response = Response.getResponse();
try {
PageData request = this.getPageData();
usersCacheService.resetPassword(request);
return response.OK();
} catch (Exception e) {
e.printStackTrace();
return response.errorMessage(e.getMessage());
}
}
/**
* 用户人脸
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/editUserFace")
@ResponseBody
public Object editUserFace() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
PageData faceBase64 = new PageData();
if (pd.get("USERAVATARURL") != null && !pd.getString("USERAVATARURL").equals("")) {
try {
FaceUtil.compareFace(pd.getString("USERAVATARURL"), pd.getString("USERAVATARURL"));
} catch (Exception e) {
map.put("result", "error");
map.put("msg", "人脸图像不符合要求 请重新上传!");
return map;
}
MultipartFile FFILE = ImageUtil.base64ToMultipartFile(pd.getString("USERAVATARPREFIX") + pd.getString("USERAVATARURL"));
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + FFILE.getOriginalFilename().substring(FFILE.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(FFILE, fileName, Const.FILEPATHUSERFACE + ffile);
faceBase64.put("COVERPATH", Const.FILEPATHUSERFACE + ffile + "/" + fileName);
} else {
map.put("result", "error");
map.put("msg", "未上传人脸识别照片,请先认证人脸!");
return map;
}
initPageDataUtil.initSaveApp(faceBase64, pd.getString("USER_ID"));
faceBase64.put("BASE_FACTORY_ID", this.get32UUID());
faceBase64.put("TABLE_NAME", "SYS_USERINFO");
faceBase64.put("COLUMN_NAME", "USER_ID");
faceBase64.put("USERAVATARPREFIX", pd.getString("USERAVATARPREFIX"));
faceBase64.put("FOREIGN_KEY", pd.get("USER_ID"));
faceBase64.put("TYPE", "1");
baseFactoryMapper.deleteByForeign(faceBase64);
baseFactoryMapper.save(faceBase64);
pd.put("AUTHENTICATION", "1");
userInfoService.editAuthentication(pd);
PageData user = new PageData();
user.put("USER_ID", pd.get("USER_ID"));
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart(pd.getString("USERAVATARPREFIX") + pd.getString("USERAVATARURL"));
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFACE + ffile);
user.put("PORTRAIT", Const.FILEPATHFACE + ffile + "/" + fileName);
userInfoService.editUserInfo(user);
map.put("result", errInfo);
return map;
}
/**
* 用户人脸
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/compareFace")
@ResponseBody
public Object compareFace() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("TYPE", "1");
pd.put("FOREIGN_KEY", pd.get("USER_ID"));
PageData user = baseFactoryMapper.findByKeyType(pd);
if (user == null || user.get("COVERPATH") == null || user.get("COVERPATH") == "") {
map.put("result", "error");
map.put("msg", "用户未录入人脸信息,无法验证");
return map;
}
MultipartFile coverpath = ImageUtil.getMultipartFile(Const.HTTPFILEURL + user.getString("COVERPATH"));
String USERAVATARURL = Base64Util.getBase64String(coverpath);
try {
String confidence = FaceUtil.compareFace(pd.getString("USERAVATARURL"), USERAVATARURL);
if (Double.valueOf(confidence) < 75) {
map.put("result", "error");
map.put("msg", "与本人不符");
// 记录 0 正常 1失败
// faceImg.put("IS_SUCCESS", 1);
// faceImgLogService.save(faceImg);
return map;
} else {
PageData student = studentMapper.findById(pd);
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart(pd.getString("USERAVATARPREFIX") + pd.getString("USERAVATARURL"));
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile);
PageData faceImg = new PageData();
faceImg.put("FACEIMGLOG_ID", this.get32UUID());
faceImg.put("CORPINFO_ID", student.get("CORPINFO_ID"));
faceImg.put("STUDENT_ID", student.get("STUDENT_ID"));
faceImg.put("USER_ID", pd.get("USER_ID"));
faceImg.put("FILEPATH", Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile + "/" + fileName);
faceImg.put("CLASS_ID", pd.get("CLASS_ID"));
faceImg.put("CURRICULUM_ID", pd.get("CURRICULUM_ID"));
faceImg.put("CHAPTER_ID", pd.get("CHAPTER_ID"));
faceImg.put("VIDEOCOURSEWARE_ID", pd.get("VIDEOCOURSEWARE_ID"));
initPageDataUtil.initSaveApp(faceImg, pd.getString("USER_ID"));
// faceImg.put("IS_SUCCESS", 0);
faceImgLogService.save(faceImg);
map.put("result", errInfo);
}
return map;
} catch (Exception e) {
System.out.println("----------" + e.getMessage());
map.put("result", "error");
map.put("msg", "未检测到人脸");
return map;
}
}
/**
* 用户人脸
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/compareFaceForH5")
@ResponseBody
public Object compareFaceForH5() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("TYPE", "1");
pd.put("FOREIGN_KEY", pd.get("USER_ID"));
PageData user = baseFactoryMapper.findByKeyType(pd);
if (user == null || user.get("BASE") == null || user.get("BASE") == "") {
map.put("result", "error");
map.put("msg", "用户未录入人脸信息,无法验证");
return map;
}
String USERAVATARURL = ImageAnd64Binary.upZip(user.getString("BASE"));
try {
String confidence = FaceUtil.compareFace(pd.getString("USERAVATARURL"), USERAVATARURL);
if (Double.valueOf(confidence) < 75) {
map.put("result", "error");
map.put("msg", "与本人不符");
// faceImg.put("IS_SUCCESS", 1); 移除 失败记录
// faceImgLogService.save(faceImg);
return map;
} else {
PageData student = studentMapper.findById(pd);
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart(pd.getString("USERAVATARPREFIX") + pd.getString("USERAVATARURL"));
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile);
PageData faceImg = new PageData();
faceImg.put("FACEIMGLOG_ID", this.get32UUID());
faceImg.put("ENTERPRISE_ID", student.get("ENTERPRISE_ID"));
faceImg.put("CORPINFO_ID", student.get("CORPINFO_ID"));
faceImg.put("STUDENT_ID", student.get("STUDENT_ID"));
faceImg.put("USER_ID", pd.get("USER_ID"));
faceImg.put("FILEPATH", Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile + "/" + fileName);
faceImg.put("CLASS_ID", student.get("CLASS_ID"));
faceImg.put("CURRICULUM_ID", student.get("CURRICULUM_ID"));
faceImg.put("CHAPTER_ID", student.get("CHAPTER_ID"));
faceImg.put("VIDEOCOURSEWARE_ID", pd.get("VIDEOCOURSEWARE_ID"));
initPageDataUtil.initSaveApp(faceImg, pd.getString("USER_ID"));
// faceImg.put("IS_SUCCESS", 0); 移除 失败记录
faceImgLogService.save(faceImg);
}
} catch (Exception e) {
System.out.println("----------" + e.getMessage());
map.put("result", "error");
map.put("msg", "未检测到人脸");
return map;
}
JSONObject result = new JSONObject();
result.element("type", "success");
WebSocket conn = FaceServerPool.getWebSocketByUser(pd.getString("USER_ID"));
FaceServerPool.sendMessageToUser(conn, result.toString());
map.put("result", errInfo);
return map;
}
/**
* 用户人脸
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/compareVideoFaceForH5")
public Object compareVideoFaceForH5(@RequestParam(value = "FFILE") MultipartFile videoFile) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("TYPE", "1");
pd.put("FOREIGN_KEY", pd.get("USER_ID"));
PageData user = baseFactoryMapper.findByKeyType(pd);
if (user == null || user.get("BASE") == null || user.get("BASE") == "") {
map.put("result", "error");
map.put("msg", "用户未录入人脸信息,无法验证");
return map;
}
// 获取时长
File video = FileUtil.MultipartFileToFile(videoFile);
MultimediaObject instance = new MultimediaObject(video);
MultimediaInfo multimediaInfo = instance.getInfo();
double videoTime = (double) multimediaInfo.getDuration() / 1000;
if (videoTime < 3) {
map.put("result", "error");
map.put("msg", "视频过短请上传2S以上的视频");
return map;
} else if (videoTime > 10) {
map.put("result", "error");
map.put("msg", "视频过大请上传10S内的视频");
return map;
}
List<PageData> picBase64List = FileUtil.fetchVideoToBase64List(video, 10);
if (picBase64List != null && picBase64List.size() > 0) {
String USERAVATARURL = ImageAnd64Binary.upZip(user.getString("BASE"));
for (PageData base64 : picBase64List) {
try {
String imgfile = new String();
if (base64.getString("rotate_old") != null && !base64.getString("rotate_old").isEmpty()) {
int rotate = Integer.parseInt(base64.getString("rotate_old")); //获取旋转角度
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart("data:image/jpg;base64," + base64.getString("picBase64"));
; //base64转文件
String ffile = DateUtil.getSdfTimesSSS();
File fileName = new File(PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile + ".jpg");
FileUtils.copyInputStreamToFile(file.getInputStream(), fileName); //base64转成文件图片暂存到本地
imgfile = FileUtil.rotatePhonePhoto(PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile + ".jpg", rotate); //旋转图片
}
String strImg = ImageAnd64Binary.getImageStr(imgfile); //将旋转过得图片转成base64
String confidence = FaceUtil.compareFace(strImg, USERAVATARURL);
if (Double.valueOf(confidence) >= 75) {
PageData student = studentMapper.findById(pd);
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart("data:image/jpeg;base64," + strImg);
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile);
PageData faceImg = new PageData();
faceImg.put("FACEIMGLOG_ID", this.get32UUID());
faceImg.put("ENTERPRISE_ID", student.get("ENTERPRISE_ID"));
faceImg.put("CORPINFO_ID", student.get("CORPINFO_ID"));
faceImg.put("STUDENT_ID", student.get("STUDENT_ID"));
faceImg.put("USER_ID", pd.get("USER_ID"));
faceImg.put("FILEPATH", Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile + "/" + fileName);
faceImg.put("CLASS_ID", student.get("CLASS_ID"));
faceImg.put("CURRICULUM_ID", student.get("CURRICULUM_ID"));
faceImg.put("CHAPTER_ID", student.get("CHAPTER_ID"));
faceImg.put("VIDEOCOURSEWARE_ID", pd.get("VIDEOCOURSEWARE_ID"));
initPageDataUtil.initSaveApp(faceImg, pd.getString("USER_ID"));
// faceImg.put("IS_SUCCESS", 0); 移除 失败记录
faceImgLogService.save(faceImg);
map.put("result", errInfo);
return map;
}
} catch (Exception e) {
System.out.println("----------" + e.getMessage());
map.put("result", "error");
map.put("msg", "未检测到人脸");
return map;
}
}
// 所有照片都不符合时,返回这个
map.put("result", "error");
map.put("msg", "与本人不符");
// faceImg.put("IS_SUCCESS", 1); 移除 失败记录
// faceImgLogService.save(faceImg);
return map;
}
JSONObject result = new JSONObject();
result.element("type", "success");
WebSocket conn = FaceServerPool.getWebSocketByUser(pd.getString("USER_ID"));
FaceServerPool.sendMessageToUser(conn, result.toString());
map.put("result", errInfo);
return map;
}
/**
* 用户人脸
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/editUserVideoFace")
public Object editUserVideoFace(@RequestParam(value = "FFILE") MultipartFile videoFile) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
// 获取时长
File video = FileUtil.MultipartFileToFile(videoFile);
MultimediaObject instance = new MultimediaObject(video);
MultimediaInfo result = instance.getInfo();
double videoTime = (double) result.getDuration() / 1000;
if (videoTime < 3) {
map.put("result", "error");
map.put("msg", "视频过短请上传2S以上的视频");
return map;
} else if (videoTime > 10) {
map.put("result", "error");
map.put("msg", "视频过大请上传10S内的视频");
return map;
}
PageData faceBase64 = new PageData();
List<PageData> picBase64List = FileUtil.fetchVideoToBase64List(video, 10);
if (picBase64List != null && picBase64List.size() > 0) {
for (PageData base64 : picBase64List) {
try {
FaceUtil.compareFace(base64.getString("picBase64"), base64.getString("picBase64"));
String imgfile = new String();
if (base64.getString("rotate_old") != null && !base64.getString("rotate_old").isEmpty()) {
int rotate = Integer.parseInt(base64.getString("rotate_old")); //获取旋转角度
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart("data:image/jpg;base64," + base64.getString("picBase64"));
; //base64转文件
String ffile = DateUtil.getSdfTimesSSS();
File fileName = new File(PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile + ".jpg");
FileUtils.copyInputStreamToFile(file.getInputStream(), fileName); //base64转成文件图片暂存到本地
imgfile = FileUtil.rotatePhonePhoto(PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile + ".jpg", rotate); //旋转图片
}
String strImg = ImageAnd64Binary.getImageStr(imgfile); //将旋转过得图片转成base64
String USERAVATARURL64 = ImageAnd64Binary.zipBase64(strImg);
faceBase64.put("BASE", USERAVATARURL64);
initPageDataUtil.initSaveApp(faceBase64, pd.getString("USER_ID"));
faceBase64.put("BASE_FACTORY_ID", this.get32UUID());
faceBase64.put("TABLE_NAME", "SYS_USER");
faceBase64.put("COLUMN_NAME", "USER_ID");
faceBase64.put("USERAVATARPREFIX", "data:image/jpeg;base64,");
faceBase64.put("FOREIGN_KEY", pd.get("USER_ID"));
faceBase64.put("TYPE", "1");
baseFactoryMapper.deleteByForeign(faceBase64);
baseFactoryMapper.save(faceBase64);
initPageDataUtil.initEditApp(pd, pd.getString("USER_ID"));
pd.put("AUTHENTICATION", "1");
usersCacheService.editAuthentication(pd);
PageData user = new PageData();
user.put("USER_ID", pd.get("USER_ID"));
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart("data:image/jpeg;base64," + strImg);
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFACE + ffile);
user.put("PORTRAIT", Const.FILEPATHFACE + ffile + "/" + fileName);
initPageDataUtil.initEditApp(user, pd.getString("USER_ID"));
usersCacheService.editUser(user);
map.put("result", errInfo);
return map;
} catch (Exception e) {
System.out.println("----------" + e.getMessage());
System.out.println("人脸图像不符合要求 请重新上传!");
}
}
// 所有照片都不符合时,返回这个
map.put("result", "error");
map.put("msg", "人脸图像不符合要求 请重新上传!");
// faceImg.put("IS_SUCCESS", 1); 移除 失败记录
// faceImgLogService.save(faceImg);
return map;
}
return map;
}
/**
* 用户人脸(上传视频)
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/compareVideoFace")
public Object compareVideoFace(@RequestParam(value = "FFILE") MultipartFile videoFile) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("TYPE", "1");
pd.put("FOREIGN_KEY", pd.get("USER_ID"));
PageData user = baseFactoryMapper.findByKeyType(pd);
if (user == null || user.get("BASE") == null || user.get("BASE") == "") {
map.put("result", "error");
map.put("msg", "用户未录入人脸信息,无法验证");
return map;
}
// 获取时长
File video = FileUtil.MultipartFileToFile(videoFile);
MultimediaObject instance = new MultimediaObject(video);
MultimediaInfo result = instance.getInfo();
double videoTime = (double) result.getDuration() / 1000;
if (videoTime < 3) {
map.put("result", "error");
map.put("msg", "视频过短请上传2S以上的视频");
return map;
} else if (videoTime > 10) {
map.put("result", "error");
map.put("msg", "视频过大请上传10S内的视频");
return map;
}
List<PageData> picBase64List = FileUtil.fetchVideoToBase64List(video, 10);
if (picBase64List != null && picBase64List.size() > 0) {
String USERAVATARURL = ImageAnd64Binary.upZip(user.getString("BASE"));
for (PageData base64 : picBase64List) {
try {
String imgfile = new String();
if (base64.getString("rotate_old") != null && !base64.getString("rotate_old").isEmpty()) {
int rotate = Integer.parseInt(base64.getString("rotate_old")); //获取旋转角度
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart("data:image/jpg;base64," + base64.getString("picBase64"));
; //base64转文件
String ffile = DateUtil.getSdfTimesSSS();
File fileName = new File(PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile + ".jpg");
FileUtils.copyInputStreamToFile(file.getInputStream(), fileName); //base64转成文件图片暂存到本地
imgfile = FileUtil.rotatePhonePhoto(PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile + ".jpg", rotate); //旋转图片
}
String strImg = ImageAnd64Binary.getImageStr(imgfile); //将旋转过得图片转成base64
String confidence = FaceUtil.compareFace(strImg, USERAVATARURL);
if (Double.valueOf(confidence) >= 75) {
PageData student = studentMapper.findById(pd);
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart("data:image/jpeg;base64," + strImg);
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile);
PageData faceImg = new PageData();
faceImg.put("FACEIMGLOG_ID", this.get32UUID());
faceImg.put("ENTERPRISE_ID", student.get("ENTERPRISE_ID"));
faceImg.put("CORPINFO_ID", student.get("CORPINFO_ID"));
faceImg.put("STUDENT_ID", student.get("STUDENT_ID"));
faceImg.put("USER_ID", pd.get("USER_ID"));
faceImg.put("FILEPATH", Const.FILEPATHFACE + student.get("CORPINFO_ID") + "/" + ffile + "/" + fileName);
faceImg.put("CLASS_ID", pd.get("CLASS_ID"));
faceImg.put("CURRICULUM_ID", pd.get("CURRICULUM_ID"));
faceImg.put("CHAPTER_ID", pd.get("CHAPTER_ID"));
faceImg.put("VIDEOCOURSEWARE_ID", pd.get("VIDEOCOURSEWARE_ID"));
initPageDataUtil.initSaveApp(faceImg, pd.getString("USER_ID"));
// faceImg.put("IS_SUCCESS", 0);
faceImgLogService.save(faceImg);
map.put("result", errInfo);
return map;
}
} catch (Exception e) {
System.out.println("----------" + e.getMessage());
map.put("result", "error");
map.put("msg", "未检测到人脸");
return map;
}
}
// 所有照片都不符合时,返回这个
map.put("result", "error");
map.put("msg", "与本人不符");
// faceImg.put("IS_SUCCESS", 1); 移除 失败记录
// faceImgLogService.save(faceImg);
return map;
}
map.put("result", errInfo);
return map;
}
/**
* 保存用户证件照
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/updateUserIdFile")
@ResponseBody
@Transactional
public Object updateUserIdFile(
@RequestParam(value = "FFILE", required = false) MultipartFile[] files
) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
String msg = "";
PageData pd = new PageData();
pd = this.getPageData();
PageData user = usersCacheService.findById(pd);
if (null == user) {
errInfo = "error";
msg = "未找到用户信息,请刷新后再次尝试!";
}
if (files != null && files.length > 0) {
MultipartFile file = files[0];
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFILE + ffile);
pd.put("ID_PHOTO", Const.FILEPATHFILE + ffile + "/" + fileName);
pd.put("USER_ID", user.getString("USER_ID"));
initPageDataUtil.initEditApp(pd, user.getString("USER_ID"));
usersCacheService.editPhoto(pd);
}
map.put("result", errInfo);
map.put("FILE_PATH", pd.get("ID_PHOTO"));
return map;
}
/**
* 保存用户签字信息
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/updateUserSign")
@ResponseBody
@Transactional
public Object updateUserSign(
@RequestParam(value = "FFILE", required = false) MultipartFile[] files
) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
String msg = "";
PageData pd = new PageData();
pd = this.getPageData();
PageData user = usersCacheService.findById(pd);
if (null == user) {
errInfo = "error";
msg = "未找到用户信息,请刷新后再次尝试!";
}
if (files != null && files.length > 0) {
MultipartFile file = files[0];
String ffile = DateUtil.getDays();
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATH_USER_SIGN + "/" + ffile);
pd.put("SIGNATURE_FILE_PATH", Const.FILEPATH_USER_SIGN + "/" + ffile + "/" + fileName);
pd.put("USER_ID", user.getString("USER_ID"));
initPageDataUtil.initEditApp(pd, user.getString("USER_ID"));
userInfoService.editUserSign(pd);
}
map.put("result", errInfo);
return map;
}
/**
* 获取学员信息
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/goEditUser")
@ResponseBody
public Object goEditUser() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
PageData stu = archivesstudentService.getUserInfo(pd);
pd = archivesstudentService.findById(pd); //根据ID读取
if (pd != null) {
stu.putAll(pd);
}
String year = stu.getString("USER_ID_CARD").substring(6).substring(0, 4);// 得到年份
String month = stu.getString("USER_ID_CARD").substring(10).substring(0, 2);// 得到月份
String day = stu.getString("USER_ID_CARD").substring(12).substring(0, 2);// 得到日
stu.put("DATE_OF_BIRTH", year + "-" + month + "-" + day); // 出生年月
map.put("pd", stu);
map.put("result", errInfo);
return map;
}
/**
* 获取学员所在单位列表
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/getUserEnterprise")
@ResponseBody
public Object getUserEnterprise(Page page) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
page.setPd(pd);
List<PageData> entList = usersCacheService.getUserEnterprise(page);
map.put("varList", entList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
}