Merge branch 'develop' of http://192.168.10.125/k18_web/NFS.git into develop

This commit is contained in:
leijun
2018-11-21 19:11:31 +08:00
3 changed files with 146 additions and 14 deletions

View File

@@ -140,7 +140,7 @@ public class MultipartFileIntercepter extends CommonsMultipartResolver{
fileTypes=Constants.LOGO_FILE_TYPE;
fileMaxSize=Constants.LOGO_SINGLE_FILE_MAX_SIZE;
}else if(functionId.equals(632)){ //人脸识别
fileTypes=Constants.FACE_FILE_TYPE;
fileTypes=Constants.PICTURE_FILE_TYPE;//同图片类型
fileMaxSize=Constants.FACE_SINGLE_FILE_MAX_SIZE;
}else if(functionId.equals(570)){ //证书管理
fileTypes=Constants.PUBLIC_FILE_TYPE;

View File

@@ -224,7 +224,6 @@ public class AvController extends BaseController {
||Constants.VIDEO_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false))
||Constants.VOIP_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false))
||Constants.SPEAKER_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false))
||Constants.FACE_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false))
){
if(!validateAvDuration(uploadSrcFile)){
addMessage(redirectAttributes,"exceeds_duration_limit");
@@ -616,7 +615,55 @@ public class AvController extends BaseController {
}
return map;
}
/**
* 上传图片文件,调用脚本压缩图片,返回图片保存路径
* @param cfg
* @param functionId
* @param redirectAttributes
* @return
*/
@ResponseBody
@RequestMapping(value = {"/sample/faceToPicture"})
public Map faceToPicture(Model model,@RequestParam("srcFile") CommonsMultipartFile[] srcFile){
String sep = System.getProperty("file.separator");
String random = UUID.randomUUID()+"";
// String srcFilePath = Constants.AV_FILE_PATH+"face"+random+sep+"srcFile";//视频源文件保存路径
String srcFilePath = StringUtils.getUserfilesBaseDir()+"face"+sep+"picFile"+sep+random+sep;//视频生成的关键帧图片文件保存路径
FileUtils.createDirectory(srcFilePath);
//保存源文件
for (CommonsMultipartFile sinFile : srcFile) {
String srcFileAllPath = srcFilePath+sep+random+FileUtils.getSuffix(sinFile.getOriginalFilename(), true);//新的文件名
File uploadSrcFile = new File(srcFileAllPath);
try {
FileCopyUtils.copy(sinFile.getBytes(), uploadSrcFile);
} catch (IOException e) {
logger.error(e);
e.printStackTrace();
}
}
Map map = new HashMap();
map.put("picFilePath", srcFilePath);
//获取图片列表
Collection<File> files = FileUtils.listFiles(new File(srcFilePath), null, true);
String srcPath = null;
for(File f:files){
if(srcPath==null){
srcPath = f.getName();
}else{
srcPath += "|"+f.getName();
}
}
//将图片文件列表赋值给生成样例的源文件路径参数
map.put("srcPath", srcPath);
map.put("status", 1);
map.put("msg", "success");
return map;
}
@RequestMapping(value = {"/sample/selectVedioPicture"})
public String selectVedioPicture(Model model,HttpServletRequest request,String picFilePath,String srcPath){
Collection<File> files = FileUtils.listFiles(new File(picFilePath), null, true);

View File

@@ -5,16 +5,16 @@
<title><spring:message code="${cfgName}"></spring:message></title>
<script type="text/javascript">
$(function(){
var ifSubmit=true;
var sfd = $("#functionId").val();
var fileType=[];
if(sfd==28||sfd==630){
fileType=["mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv","wav","mp3"];
}
if(sfd==29||sfd==631){
if(sfd==29){
fileType=["mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv"];
}
if(sfd==30||sfd==632){
if(sfd==30||sfd==632||sfd==631){
fileType=["bmp","jpg","tiff","raw","gif"];
}
if(sfd==31){
@@ -45,9 +45,9 @@ $(function(){
$("#srcFile").trigger("click");
});
$("#srcFile").on('change',function(){
if(sampleFileValidate(fileType,$("#srcFile").val())){
if(sfd!=632&&sampleFileValidate(fileType,$("#srcFile").val())){
//样例文件类型正确进行后续处理
$("#srcFileInfo").val($("#srcFile").val());
var videoToPicture = $("#videoToPicture").val();
@@ -74,6 +74,65 @@ $(function(){
var url = "${ctx}/ntc/av/sample/selectVedioPicture?picFilePath="+encodeURIComponent(data.picFilePath);
//openPicWindow(url);
}else{
// alert(data.msg);
top.$.jBox.tip(data.msg, "<spring:message code='info'/>");
return;
}
},
error:function(jqXHR, textStatus, errorThrown){
top.$.jBox.closeTip();
//alert(jqXHR.responseText);
top.$.jBox(jqXHR.responseText,{
width: $(document).width()*0.9,
height:$(document).height()*0.8,
top: '10%',
draggable:false,
title: "Error Info", buttons:{ "close":true}
});
return false;
}
});
}
}
// 人脸识别
if(sfd==632){
var files = $(this)[0].files;
for(var i = 0;i < files.length;i ++) {
var file = files[i];
var faceName = file.name;
var vals=sampleFileValidate(fileType,faceName)
if (!vals){
ifSubmit=false;
return;
}else{
ifSubmit=true;
}
}
if(ifSubmit){
$("#srcFileInfo").val($("#srcFile").val());
var srcFacePath =$("#srcPath").val();
var fd = new FormData($('#cfgFrom')[0]);
$.ajax({
url: "${ctx}/ntc/av/sample/faceToPicture",
type: "POST",
processData: false,
contentType: false,
data: fd,
async: true,
cache: false,
beforeSend: function(){
loading('onloading...');
},
success: function(data) {
top.$.jBox.closeTip();
if(data.status==1){
$("#picPath").val(data.picFilePath);
$("#srcPath").val(data.srcPath);
$("#showPicture").removeClass("hidden");
var url = "${ctx}/ntc/av/sample/selectVedioPicture?picFilePath="+encodeURIComponent(data.picFilePath);
//openPicWindow(url);
}else{
alert(data.msg);
}
@@ -91,8 +150,8 @@ $(function(){
return false;
}
});
}
}
}
});
/* $("#uploadSample,#sampleFileInfo").on('click',function(){
$("#sampleFile").trigger("click");
@@ -127,8 +186,13 @@ $(function(){
var srcFile = $("#srcFile").val();
if(srcFile!=''){
if(!sampleFileValidate(fileType,srcFile)){
if(!ifSubmit){
$("#fileErrorNote").append("<label id='level-error' class='error'><spring:message code='file_in_wrong_format'/></label>");
return false;
}else{
if(!sampleFileValidate(fileType,srcFile)){
return false;
}
}
}
@@ -137,7 +201,7 @@ $(function(){
var srcPath = $("#srcPath").val();
//var sampleUrl = $("#sampleUrl").val();
var videoToPicture = $("#videoToPicture").val();
if(videoToPicture=="true"){
if(videoToPicture=="true"&&sfd!=632){
if((srcUrl==null||srcUrl=="") && (srcPath==null || srcPath=="")){//srcUrl判断修改时未重新上传文件srcPath判断修改时重新上传文件但未选择关键帧图片
$("div[for='srcFileInfo']").append("<label id='level-error' class='error' for='srcFile'><spring:message code='keyframe_pic_required'></spring:message></label>");
return false;
@@ -204,7 +268,6 @@ function hiddenlevel(){
// 校验文件后缀名
function sampleFileValidate(fileType,fileName){
var flag=false; //状态,检测文件后缀用
var arr=fileType;//使用是什么格式的后缀
var cFile=fileName;//文件的值
@@ -306,12 +369,14 @@ function sampleFileValidate(fileType,fileName){
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="src_file"/></label>
<div class="col-md-6">
<%-- <input class="form-control required" type="text" name="srcUrl" value="${_cfg.srcUrl }"> --%>
<input id="srcFile" type="file" name="srcFile" style="width: 330px;display:none" />
<c:if test="${_cfg.functionId != 632}">
<input id="srcFile" type="file" name="srcFile" style="width: 330px;display:none" />
</c:if>
<c:set var="videoToPicture" value="${fns:getDictLabel('VIDEO_TO_PICTURE', _cfg.functionId, 'false')}" />
<input type="hidden" name="videoToPicture" id="videoToPicture" value="${videoToPicture }">
<c:choose>
<c:when test="${videoToPicture}">
<c:when test="${videoToPicture and _cfg.functionId != 632}">
<input id="srcPath" name="srcPath" type="hidden" style="width: 330px;" />
<div class="input-group">
<input id="srcFileInfo" name="srcFileInfo" readonly="readonly" data-msg-required=""
@@ -328,6 +393,26 @@ function sampleFileValidate(fileType,fileName){
<i class="fa btn-search"></i>
<spring:message code="show"></spring:message></button>
</c:when>
<c:when test="${_cfg.functionId eq 632}">
<input id="srcFile" type="file" name="srcFile" style="width: 330px;display:none" multiple/>
<input id="srcPath" name="srcPath" type="hidden" style="width: 330px;"/>
<div class="input-group">
<input id="srcFileInfo" name="srcFileInfo" readonly="readonly" data-msg-required=""
placeholder="<spring:message code="select_file"/>" class="required form-control" style=" background-color:transparent"
aria-required="true" type="text" value="${_cfg.srcUrl }">
<div class="input-group-btn">
<a id="uploadSrc" class="btn btn-default btn-search " href="javascript:" style=""><i class="fa fa-search"></i></a>
</div>
</div>
<input id="srcUrl" name="srcUrl" type="hidden" value="${_cfg.srcUrl }"/>
<button type="button" id="showPicture" class="btn btn-warning hidden ">
<i class="fa btn-search"></i>
<spring:message code="show"></spring:message></button>
</c:when>
<c:otherwise>
<div class="input-group">
<input id="srcFileInfo" name="srcFileInfo" readonly="readonly" data-msg-required=""