完成添加项目功能。
This commit is contained in:
parent
f98e06872a
commit
147afd7258
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.dfm.controller;
|
package com.ruoyi.dfm.controller;
|
||||||
|
|
||||||
import com.ruoyi.dfm.pojo.UserInfo;
|
import com.ruoyi.dfm.pojo.UserInfo;
|
||||||
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
@ -36,8 +37,6 @@ public class BaseController {
|
||||||
|
|
||||||
protected UserInfo getUserInfo(HttpServletRequest req)
|
protected UserInfo getUserInfo(HttpServletRequest req)
|
||||||
{
|
{
|
||||||
UserInfo user = null;
|
return ShiroUtils.getLoginUser();
|
||||||
user = (UserInfo)req.getSession().getAttribute("user");
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.dfm.controller;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.dfm.constant.UserConstants;
|
import com.ruoyi.dfm.constant.UserConstants;
|
||||||
import com.ruoyi.dfm.pojo.*;
|
import com.ruoyi.dfm.pojo.*;
|
||||||
import com.ruoyi.dfm.service.FileService;
|
import com.ruoyi.dfm.service.FileService;
|
||||||
|
|
@ -17,8 +18,10 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
import org.springframework.web.multipart.MultipartResolver;
|
import org.springframework.web.multipart.MultipartResolver;
|
||||||
//import org.springframework.web.multipart.cos.CosMultipartResolver;
|
//import org.springframework.web.multipart.cos.CosMultipartResolver;
|
||||||
|
|
@ -62,15 +65,16 @@ public class ProjectController extends BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/addSave")
|
@RequestMapping("/addSave")
|
||||||
public ModelAndView add(HttpServletRequest request, HttpServletResponse res)
|
@ResponseBody
|
||||||
|
public AjaxResult add(HttpServletRequest req, HttpServletResponse res, @RequestParam("pcbFile") MultipartFile pcbFile, @RequestParam(value = "bomFile", required = false) MultipartFile bomFile)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//FIXME 修改上传文件
|
//FIXME 修改上传文件
|
||||||
MultipartResolver cmr = null;//new CosMultipartResolver(request.getSession().getServletContext());
|
// MultipartResolver cmr = null;//new CosMultipartResolver(request.getSession().getServletContext());
|
||||||
|
|
||||||
MultipartHttpServletRequest req = cmr.resolveMultipart(request);
|
// MultipartHttpServletRequest req = cmr.resolveMultipart(request);
|
||||||
|
|
||||||
String projectName = req.getParameter("projectName");
|
String projectName = req.getParameter("projectName");
|
||||||
String[] dfmCheckArr = req.getParameterValues("dfmCheck");
|
String[] dfmCheckArr = req.getParameterValues("dfmCheck");
|
||||||
|
|
@ -137,7 +141,7 @@ public class ProjectController extends BaseController
|
||||||
|
|
||||||
project.setReportLanguage(reportLanguage);
|
project.setReportLanguage(reportLanguage);
|
||||||
|
|
||||||
UserInfo user = getUserInfo(req);
|
UserInfo user = ShiroUtils.getLoginUser();
|
||||||
project.setSubmitUser(user.getId());
|
project.setSubmitUser(user.getId());
|
||||||
project.setSubmitUserName(user.getUsername());
|
project.setSubmitUserName(user.getUsername());
|
||||||
project.setSubmitTime(TimeUtil.getNowChar14());
|
project.setSubmitTime(TimeUtil.getNowChar14());
|
||||||
|
|
@ -159,13 +163,16 @@ public class ProjectController extends BaseController
|
||||||
|
|
||||||
project.setCCtoOther(ccEmail);
|
project.setCCtoOther(ccEmail);
|
||||||
|
|
||||||
this.projectService.addProject(req, project);
|
this.projectService.addProject(ShiroUtils.getLoginUser(), pcbFile, bomFile, project);
|
||||||
outputMsg(res, "<script>alert('添加项目成功,点击确定继续添加!');document.location.href='project.do?method=getAddPage';</script>");
|
// outputMsg(res, "<script>alert('添加项目成功,点击确定继续添加!');document.location.href='project.do?method=getAddPage';</script>");
|
||||||
return null;
|
// return null;
|
||||||
|
return AjaxResult.success();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("添加项目失败", e);
|
logger.error("添加项目失败", e);
|
||||||
outputMsg(res, "<script>alert('添加项目失败,请检查数据正确性,重新添加!');document.location.href='project.do?method=getAddPage';</script>"); }
|
// outputMsg(res, "<script>alert('添加项目失败,请检查数据正确性,重新添加!');document.location.href='project.do?method=getAddPage';</script>"); }
|
||||||
return null;
|
//// return null;
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/getLastVersion")
|
@RequestMapping("/getLastVersion")
|
||||||
|
|
@ -872,7 +879,8 @@ public class ProjectController extends BaseController
|
||||||
project.getProjectName() + "/" + "Ver" + project.getVersion();
|
project.getProjectName() + "/" + "Ver" + project.getVersion();
|
||||||
|
|
||||||
List<FileInfo> fileList = new ArrayList<FileInfo>();
|
List<FileInfo> fileList = new ArrayList<FileInfo>();
|
||||||
this.fileService.savePhysicFile(req, fileList, dir, true, "pre-");
|
//FIXME 修复上传文件错误
|
||||||
|
// this.fileService.savePhysicFile(req, fileList, dir, true, "pre-");
|
||||||
projectService.updateProjectPreDFMFile(pid, fileList.get(0).getId(), fileList.get(0).getFileName());
|
projectService.updateProjectPreDFMFile(pid, fileList.get(0).getId(), fileList.get(0).getFileName());
|
||||||
req.setAttribute("uploadResult", "上传成功");
|
req.setAttribute("uploadResult", "上传成功");
|
||||||
req.setAttribute("uploadType", "preDFM");
|
req.setAttribute("uploadType", "preDFM");
|
||||||
|
|
@ -916,7 +924,8 @@ public class ProjectController extends BaseController
|
||||||
project.getProjectName() + "/" + "Ver" + project.getVersion();
|
project.getProjectName() + "/" + "Ver" + project.getVersion();
|
||||||
|
|
||||||
List<FileInfo> fileList = new ArrayList<FileInfo>();
|
List<FileInfo> fileList = new ArrayList<FileInfo>();
|
||||||
this.fileService.savePhysicFile(req, fileList, dir, true, "post-");
|
//FIXME 修复上传文件错误
|
||||||
|
// this.fileService.savePhysicFile(req, fileList, dir, true, "post-");
|
||||||
|
|
||||||
projectService.updateProjectPostDFMFile(pid, fileList.get(0).getId(), fileList.get(0).getFileName());
|
projectService.updateProjectPostDFMFile(pid, fileList.get(0).getId(), fileList.get(0).getFileName());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,3 +135,6 @@ xss:
|
||||||
swagger:
|
swagger:
|
||||||
# 是否开启swagger
|
# 是否开启swagger
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
#上传文件根路径
|
||||||
|
FILE_PHYSICAL_ROOT: E:/FileRoot/
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
<head>
|
<head>
|
||||||
<th:block th:include="include :: header('新增项目')" />
|
<th:block th:include="include :: header('新增项目')" />
|
||||||
<th:block th:include="include :: select2-css" />
|
<th:block th:include="include :: select2-css" />
|
||||||
|
<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<form id="form-project-add" class="form-horizontal">
|
<form id="form-project-add" class="form-horizontal" enctype="multipart/form-data">
|
||||||
<!--<input name="deptId" type="hidden" id="treeId"/>-->
|
<!--<input name="deptId" type="hidden" id="treeId"/>-->
|
||||||
<h4 class="form-header h4">任务描述</h4>
|
<h4 class="form-header h4">任务描述</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -14,7 +15,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">任务类型:</label>
|
<label class="col-sm-4 control-label is-required">任务类型:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="checkType" name="checkType" onchange="showDfmCheck(this);" class="form-control m-b">
|
<select id="checkType" name="checkType" onchange="showDfmCheck(this);" class="form-control m-b" required>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -189,7 +190,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">PCB文件包:</label>
|
<label class="col-sm-4 control-label is-required">PCB文件包:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="file" id="pcbFile" name="pcbFile" class="form-control" onblur="fillProjectName(this);"/>
|
<input type="file" id="pcbFile" name="pcbFile" class="form-control" onblur="fillProjectName(this);" required/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -209,7 +210,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">BOM文件:</label>
|
<label class="col-sm-4 control-label">BOM文件:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="file" name="bomFile" id="bomFile" class="form-control" />
|
<input type="file" name="bomFile" id="bomFile" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -235,7 +236,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">单板类型:</label>
|
<label class="col-sm-4 control-label is-required">单板类型:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="pcbType" class="form-control m-b">
|
<select name="pcbType" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -244,7 +245,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">HDI层叠方式:</label>
|
<label class="col-sm-4 control-label is-required">HDI层叠方式:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="hdiModel" class="form-control m-b">
|
<select name="hdiModel" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -264,7 +265,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">拼板方式:</label>
|
<label class="col-sm-4 control-label is-required">拼板方式:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="panelModel" class="form-control m-b">
|
<select name="panelModel" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -303,7 +304,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">辅助边位置:</label>
|
<label class="col-sm-4 control-label is-required">辅助边位置:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="railwayPosition" class="form-control m-b">
|
<select name="railwayPosition" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -318,7 +319,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">是否无铅:</label>
|
<label class="col-sm-4 control-label is-required">是否无铅:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="havePb" class="form-control m-b">
|
<select name="havePb" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -327,7 +328,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">Top工艺路线:</label>
|
<label class="col-sm-4 control-label is-required">Top工艺路线:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="assemblyProcessTop" class="form-control m-b">
|
<select name="assemblyProcessTop" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -339,7 +340,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">表面处理方式:</label>
|
<label class="col-sm-4 control-label is-required">表面处理方式:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="surfaceProcess" class="form-control m-b">
|
<select name="surfaceProcess" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -348,7 +349,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">Bottom工艺路线:</label>
|
<label class="col-sm-4 control-label is-required">Bottom工艺路线:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="assemblyProcessBot" class="form-control m-b">
|
<select name="assemblyProcessBot" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -360,7 +361,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">主要面:</label>
|
<label class="col-sm-4 control-label is-required">主要面:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="primarySide" class="form-control m-b">
|
<select name="primarySide" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -369,7 +370,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">Top回流过板方向:</label>
|
<label class="col-sm-4 control-label is-required">Top回流过板方向:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="directionTop" class="form-control m-b">
|
<select name="directionTop" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -381,7 +382,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">Bottom回流过板方向:</label>
|
<label class="col-sm-4 control-label is-required">Bottom回流过板方向:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="directionBot" class="form-control m-b">
|
<select name="directionBot" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -390,7 +391,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">Bottom波峰过板方向:</label>
|
<label class="col-sm-4 control-label is-required">Bottom波峰过板方向:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select name="directionBotFs" class="form-control m-b">
|
<select name="directionBotFs" class="form-control m-b" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -402,7 +403,7 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-offset-5 col-sm-10">
|
<div class="col-sm-offset-5 col-sm-10">
|
||||||
<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>
|
<button type="submit" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>
|
||||||
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
|
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -421,57 +422,121 @@
|
||||||
$("#form-project-add").validate({
|
$("#form-project-add").validate({
|
||||||
onkeyup: false,
|
onkeyup: false,
|
||||||
rules:{
|
rules:{
|
||||||
name:{
|
projectName:{
|
||||||
minlength: 1,
|
minlength: 6,
|
||||||
maxlength: 32
|
|
||||||
},
|
|
||||||
username:{
|
|
||||||
minlength: 1,
|
|
||||||
maxlength: 32
|
|
||||||
},
|
|
||||||
password:{
|
|
||||||
minlength: 4,
|
|
||||||
maxlength: 32
|
|
||||||
},
|
|
||||||
password1:{
|
|
||||||
minlength: 4,
|
|
||||||
maxlength: 32,
|
maxlength: 32,
|
||||||
equalTo: "#password"
|
|
||||||
},
|
},
|
||||||
email:{
|
boardThickness:{
|
||||||
email:true,
|
number: true
|
||||||
|
},
|
||||||
|
maxHeightTop:{
|
||||||
|
number: true
|
||||||
},
|
},
|
||||||
ccEmail:{
|
subPcbNum:{
|
||||||
email:true,
|
number: true
|
||||||
},
|
},
|
||||||
department:{
|
maxHeightBot:{
|
||||||
|
number: true
|
||||||
},
|
}
|
||||||
projectGroup:{
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
messages: {
|
|
||||||
password1: {
|
|
||||||
required: "请再次输入新密码",
|
|
||||||
equalTo: "两次密码输入不一致"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
focusCleanup: true
|
focusCleanup: true
|
||||||
});
|
});
|
||||||
|
|
||||||
function submitHandler() {
|
function submitHandler() {
|
||||||
// var chrtype = [[${#strings.defaultString(@config.getKey('sys.account.chrtype'), 0)}]];
|
|
||||||
// var password = $("#password").val();
|
|
||||||
// if ($.validate.form() && checkpwd(chrtype, password)) {
|
|
||||||
if ($.validate.form() ) {
|
if ($.validate.form() ) {
|
||||||
|
var checkResult = submitForm();
|
||||||
|
if(!checkResult) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var data = $("#form-project-add").serializeArray();
|
var data = $("#form-project-add").serializeArray();
|
||||||
$.operate.save(prefix + "/addSave", data);
|
// $.operate.save(prefix + "/addSave", data);
|
||||||
|
var url = prefix + "/addSave";
|
||||||
|
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('pcbFile', $('#pcbFile')[0].files[0]);
|
||||||
|
formData.append('bomFile', $('#bomFile')[0].files[0]);
|
||||||
|
|
||||||
|
$.each( data, function(i, obj){
|
||||||
|
formData.append(obj.name, obj.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'post',
|
||||||
|
cache: false,
|
||||||
|
data: formData,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
dataType: "json",
|
||||||
|
beforeSend: function () {
|
||||||
|
$.modal.loading("正在处理中,请稍后...");
|
||||||
|
$.modal.disable();
|
||||||
|
},
|
||||||
|
success: function(result) {
|
||||||
|
$.operate.successCallback(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//验证form
|
||||||
|
function submitForm() {
|
||||||
|
|
||||||
|
if (!$.validate.form() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($.trim($("input[name='projectName']").val()) == "") {
|
||||||
|
// alert("项目名不能为空!");
|
||||||
|
$modal.alertError("项目名不能为空!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($.trim($("input[name='version']").val()) == "") {
|
||||||
|
// alert("版本不能为空!");
|
||||||
|
$modal.alertError("版本不能为空!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($("select[name='checkType']").val() == "") {
|
||||||
|
// alert("请选择任务类型!");
|
||||||
|
$modal.alertError("请选择任务类型!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkType = $("select[name='checkType']");
|
||||||
|
var dfmCheck = checkType.children(":selected").text();
|
||||||
|
//var dfmCheck = $(checkType).val();
|
||||||
|
if (dfmCheckName == dfmCheck) { //必须提供PCB文件包与BOM文件,需提供所有的单板参数、工艺参数。
|
||||||
|
// if (!doValidate('addProjectForm')) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
} else if ("BOM预审" == dfmCheck) {
|
||||||
|
//只需提供BOM文件,无需提供PCB文件包。无需提供单板参数、工艺参数。
|
||||||
|
if ($("input[name='bomFile']").val() == "") {
|
||||||
|
// alert("必需提供BOM文件!");
|
||||||
|
$modal.alertError("必需提供BOM文件!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ("CAM验证" == dfmCheck) {
|
||||||
|
//只需提供PCB文件包,无需提供BOM文件。无需提供单板参数、工艺参数。
|
||||||
|
if ($("input[name='pcbFile']").val() == "") {
|
||||||
|
// alert("必需提供PCB文件!");
|
||||||
|
$modal.alertError("必需提供PCB文件!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//显示进度条
|
||||||
|
// setTimeout(showProcess, 200);
|
||||||
|
$.modal.loading("正在上传文件,请耐心等待...");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var dfmCheckValue = '2';
|
var dfmCheckValue = '2';
|
||||||
//如有修改DFM分析自定义的名称,修改这个变量即可
|
//如有修改DFM分析自定义的名称,修改这个变量即可
|
||||||
|
//TODO 记得恢复成原样
|
||||||
var dfmCheckName = 'PCB版本对比';
|
var dfmCheckName = 'PCB版本对比';
|
||||||
|
|
||||||
//选择任务类型
|
//选择任务类型
|
||||||
|
|
@ -762,10 +827,10 @@
|
||||||
return path.substring(pos+1);
|
return path.substring(pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showProcess()
|
// function showProcess()
|
||||||
{
|
// {
|
||||||
$(document).progressDialog.showDialog("正在上传文件,请耐心等待...");
|
// $(document).progressDialog.showDialog("正在上传文件,请耐心等待...");
|
||||||
}
|
// }
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.ruoyi.dfm.util.TimeUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
@ -37,8 +38,8 @@ public class FileService {
|
||||||
// 获取系统文件根路径
|
// 获取系统文件根路径
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
rootPath = PropertiesUtils.getProperties().getProperty(
|
// rootPath = PropertiesUtils.getProperties().getProperty(
|
||||||
"FILE_PHYSICAL_ROOT");
|
// "FILE_PHYSICAL_ROOT");
|
||||||
File file = new File(rootPath);
|
File file = new File(rootPath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdir();
|
file.mkdir();
|
||||||
|
|
@ -68,7 +69,7 @@ public class FileService {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public void savePhysicFile(MultipartHttpServletRequest request, List<FileInfo> list , String filePath, boolean isRename, String reNameKey) throws Exception{
|
public void savePhysicFile(UserInfo loginUser, MultipartFile[] multipartFiles, List<FileInfo> list , String filePath, boolean isRename, String reNameKey) throws Exception{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String path = rootPath + filePath;
|
String path = rootPath + filePath;
|
||||||
|
|
@ -77,42 +78,19 @@ public class FileService {
|
||||||
log.error("创建项目文件目录失败");
|
log.error("创建项目文件目录失败");
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
/*MultipartRequest multi = new MultipartRequest(request, path,
|
// Iterator<String> it = request.getFileNames();
|
||||||
maxPostSize, fileEncoding);
|
// MultipartFile[] fileArr = new MultipartFile[]{pcbFile, bomFile};
|
||||||
Enumeration fileNames = multi.getFileNames();
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
FileInfo fileInfo;
|
FileInfo fileInfo;
|
||||||
while (fileNames.hasMoreElements()) {
|
// while (it.hasNext()) {
|
||||||
// 表单file元素name属性值
|
for(MultipartFile multipartFile : multipartFiles) {
|
||||||
String name = fileNames.nextElement().toString();
|
if(null == multipartFile) {
|
||||||
// 原文件名值
|
|
||||||
String original = multi.getOriginalFileName(name);
|
|
||||||
File file = multi.getFile(name);
|
|
||||||
if (null == file) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fileInfo = new FileInfo();
|
|
||||||
fileInfo.setFieldName(name);
|
|
||||||
fileInfo.setFileName(original);
|
|
||||||
fileInfo.setFileSize(file.length());
|
|
||||||
fileInfo.setRelaPath(filePath);
|
|
||||||
fileInfo.setUploadTime(TimeUtil.getNowChar14());
|
|
||||||
// 设置实际名称
|
|
||||||
String extendName = file.getName().substring(
|
|
||||||
file.getName().lastIndexOf(".") + 1);
|
|
||||||
fileInfo.setExtendName(extendName);
|
|
||||||
fileDAO.add(fileInfo);
|
|
||||||
list.add(fileInfo);
|
|
||||||
count++;
|
|
||||||
}*/
|
|
||||||
Iterator<String> it = request.getFileNames();
|
|
||||||
FileInfo fileInfo;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
// 表单file元素name属性值
|
// 表单file元素name属性值
|
||||||
String name = it.next();
|
// String name = it.next();
|
||||||
|
String name = multipartFile.getName();
|
||||||
// 原文件名值
|
// 原文件名值
|
||||||
MultipartFile multipartFile = request.getFile(name);
|
// MultipartFile multipartFile = request.getFile(name);
|
||||||
String original = multipartFile.getOriginalFilename();
|
String original = multipartFile.getOriginalFilename();
|
||||||
if(null == original || "".equals(original))
|
if(null == original || "".equals(original))
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +129,8 @@ public class FileService {
|
||||||
fileInfo.setFileSize(multipartFile.getSize());
|
fileInfo.setFileSize(multipartFile.getSize());
|
||||||
fileInfo.setRelaPath(filePath);
|
fileInfo.setRelaPath(filePath);
|
||||||
fileInfo.setUploadTime(TimeUtil.getNowChar14());
|
fileInfo.setUploadTime(TimeUtil.getNowChar14());
|
||||||
fileInfo.setUploadUser(((UserInfo)request.getSession().getAttribute("user")).getId());
|
// fileInfo.setUploadUser(((UserInfo)request.getSession().getAttribute("user")).getId());
|
||||||
|
fileInfo.setUploadUser(loginUser.getId());
|
||||||
// 设置实际名称
|
// 设置实际名称
|
||||||
String extendName = original.substring(original.lastIndexOf(".") + 1);
|
String extendName = original.substring(original.lastIndexOf(".") + 1);
|
||||||
fileInfo.setExtendName(extendName);
|
fileInfo.setExtendName(extendName);
|
||||||
|
|
@ -234,5 +213,9 @@ public class FileService {
|
||||||
{
|
{
|
||||||
return fileDAO.getById(fid);
|
return fileDAO.getById(fid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Value("${FILE_PHYSICAL_ROOT}")
|
||||||
|
public void setRootPath(String rootPath) {
|
||||||
|
FileService.rootPath = rootPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -29,15 +31,18 @@ public class ProjectService
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileService fileService;
|
private FileService fileService;
|
||||||
|
|
||||||
public void addProject(MultipartHttpServletRequest req, Project project) throws Exception
|
public void addProject(UserInfo loginUser, MultipartFile pcbFile, MultipartFile bomFile, Project project) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String dir = ((UserInfo)req.getSession().getAttribute("user")).getUsername() + "/" +
|
// String dir = ((UserInfo)req.getSession().getAttribute("user")).getUsername() + "/" +
|
||||||
project.getProjectName() + "/" + "Ver" + project.getVersion();
|
// project.getProjectName() + "/" + "Ver" + project.getVersion();
|
||||||
|
String dir = loginUser.getUsername() + "/" +
|
||||||
|
project.getProjectName() + "/" + "Ver" + project.getVersion();
|
||||||
|
|
||||||
|
MultipartFile[] multipartFiles = new MultipartFile[]{pcbFile, bomFile};
|
||||||
List fileList = new ArrayList();
|
List fileList = new ArrayList();
|
||||||
this.fileService.savePhysicFile(req, fileList, dir, false , null);
|
this.fileService.savePhysicFile(loginUser, multipartFiles, fileList, dir, false , null);
|
||||||
for (int i = 0; i < fileList.size(); ++i)
|
for (int i = 0; i < fileList.size(); ++i)
|
||||||
{
|
{
|
||||||
FileInfo file = (FileInfo)fileList.get(i);
|
FileInfo file = (FileInfo)fileList.get(i);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue