1.修复相关问题

This commit is contained in:
kingsfighter 2020-09-24 22:10:46 +08:00
parent 3399268f22
commit 4fa833f471
8 changed files with 121 additions and 108 deletions

View File

@ -7,3 +7,20 @@
实际: 实际:
1.完成菜单移植 1.完成菜单移植
2.完成用户列表 2.完成用户列表
2020-09-24
-- t_project表增加唯一索引
ALTER TABLE `t_project`
ADD UNIQUE INDEX `idx_name_version`(`F_PROJECT_NAME`, `F_VERSION`);
-- 修改version字段类型
ALTER TABLE `t_project`
MODIFY COLUMN `F_VERSION` varchar(100) NULL DEFAULT 1 COMMENT '版本' AFTER `F_PROJECT_NAME`;
-- 增加字段 F_Pcb_Material
ALTER TABLE `t_project`
ADD COLUMN `F_Pcb_Material` int(10) NULL AFTER `F_Direction_Bot`;
测试数据
160500
bpq0

View File

@ -14,11 +14,11 @@ import com.ruoyi.dfm.service.UserService;
import com.ruoyi.dfm.util.TimeUtil; import com.ruoyi.dfm.util.TimeUtil;
import com.ruoyi.framework.util.ShiroUtils; import com.ruoyi.framework.util.ShiroUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.aspectj.weaver.loadtime.Aj;
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.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
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.RequestParam;
@ -69,14 +69,13 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
public AjaxResult add(HttpServletRequest req, HttpServletResponse res, @RequestParam("pcbFile") MultipartFile pcbFile, @RequestParam(value = "bomFile", required = false) MultipartFile bomFile) public AjaxResult add(HttpServletRequest req, HttpServletResponse res, @RequestParam("pcbFile") MultipartFile pcbFile, @RequestParam(value = "bomFile", required = false) MultipartFile bomFile)
throws Exception throws Exception
{ {
String projectName = req.getParameter("projectName");
String version = req.getParameter("version").trim();
try try
{ {
//FIXME 修改上传文件 // String projectName = req.getParameter("projectName");
// MultipartResolver cmr = null;//new CosMultipartResolver(request.getSession().getServletContext());
// MultipartHttpServletRequest req = cmr.resolveMultipart(request);
String projectName = req.getParameter("projectName");
String[] dfmCheckArr = req.getParameterValues("dfmCheck"); String[] dfmCheckArr = req.getParameterValues("dfmCheck");
String dfmCheck = ""; String dfmCheck = "";
if (dfmCheckArr != null) if (dfmCheckArr != null)
@ -86,7 +85,8 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
dfmCheck = dfmCheck + check + ","; dfmCheck = dfmCheck + check + ",";
} }
} }
int version = (req.getParameter("version").trim() == "") ? 0 : Integer.parseInt(req.getParameter("version").trim()); //int version = (req.getParameter("version").trim() == "") ? 0 : Integer.parseInt(req.getParameter("version").trim());
// String version = req.getParameter("version").trim();
int pri = (req.getParameter("pri").trim() == "") ? 0 : Integer.parseInt(req.getParameter("pri").trim()); int pri = (req.getParameter("pri").trim() == "") ? 0 : Integer.parseInt(req.getParameter("pri").trim());
int checkType = (req.getParameter("checkType").trim() == "") ? 0 : Integer.parseInt(req.getParameter("checkType").trim()); int checkType = (req.getParameter("checkType").trim() == "") ? 0 : Integer.parseInt(req.getParameter("checkType").trim());
int pcbType = (req.getParameter("pcbType").trim() == "") ? 0 : Integer.parseInt(req.getParameter("pcbType").trim()); int pcbType = (req.getParameter("pcbType").trim() == "") ? 0 : Integer.parseInt(req.getParameter("pcbType").trim());
@ -106,6 +106,7 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
int primarySide = (req.getParameter("primarySide").trim() == "") ? 0 : Integer.parseInt(req.getParameter("primarySide").trim()); int primarySide = (req.getParameter("primarySide").trim() == "") ? 0 : Integer.parseInt(req.getParameter("primarySide").trim());
int directionBot = (req.getParameter("directionBot").trim() == "") ? 0 : Integer.parseInt(req.getParameter("directionBot").trim()); int directionBot = (req.getParameter("directionBot").trim() == "") ? 0 : Integer.parseInt(req.getParameter("directionBot").trim());
int directionBotFs = (req.getParameter("directionBotFs").trim() == "") ? 0 : Integer.parseInt(req.getParameter("directionBotFs").trim()); int directionBotFs = (req.getParameter("directionBotFs").trim() == "") ? 0 : Integer.parseInt(req.getParameter("directionBotFs").trim());
int pcbMaterial = (req.getParameter("pcbMaterial").trim() == "") ? 0 : Integer.parseInt(req.getParameter("pcbMaterial").trim());
String density = req.getParameter("density"); String density = req.getParameter("density");
String lastVersion = null == req.getParameter("lastVersion") ? "" : req.getParameter("lastVersion").trim(); String lastVersion = null == req.getParameter("lastVersion") ? "" : req.getParameter("lastVersion").trim();
@ -137,6 +138,7 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
project.setPanelModel(panelModel); project.setPanelModel(panelModel);
project.setDirectionBotFs(directionBotFs); project.setDirectionBotFs(directionBotFs);
project.setDensity(density); project.setDensity(density);
project.setPcbMaterial(pcbMaterial);
project.setLastVersion(lastVersion); project.setLastVersion(lastVersion);
project.setReportLanguage(reportLanguage); project.setReportLanguage(reportLanguage);
@ -160,17 +162,15 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
ccEmail = userCC + ";" + CCtoOther; ccEmail = userCC + ";" + CCtoOther;
} }
} }
project.setCCtoOther(ccEmail); project.setCCtoOther(ccEmail);
this.projectService.addProject(ShiroUtils.getLoginUser(), pcbFile, bomFile, project); this.projectService.addProject(ShiroUtils.getLoginUser(), pcbFile, bomFile, project);
// outputMsg(res, "<script>alert('添加项目成功,点击确定继续添加!');document.location.href='project.do?method=getAddPage';</script>");
// return null;
return AjaxResult.success(); return AjaxResult.success();
} catch (Exception e) { } catch (DuplicateKeyException e) {
logger.error("添加项目失败project={},version={}重复", projectName,version, e);
return AjaxResult.error("项目名和版本已存在");
}catch (Exception e) {
logger.error("添加项目失败", e); logger.error("添加项目失败", e);
// outputMsg(res, "<script>alert('添加项目失败,请检查数据正确性,重新添加!');document.location.href='project.do?method=getAddPage';</script>"); }
//// return null;
return AjaxResult.error(); return AjaxResult.error();
} }
} }
@ -184,14 +184,6 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
String projectName = req.getParameter("projectName"); String projectName = req.getParameter("projectName");
Project project = this.projectService.getLastVersion(uid, projectName); Project project = this.projectService.getLastVersion(uid, projectName);
return project; return project;
// String msg = "";
// if (project != null)
// {
// //msg = JSONObject.fromObject(project).toString();
// msg = JSON.toJSONString(project);
// }
//
// outputJson(res, msg);
} }
@RequestMapping("/getAttrValue") @RequestMapping("/getAttrValue")
@ -200,7 +192,6 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
{ {
String attrName = req.getParameter("attrName"); String attrName = req.getParameter("attrName");
List list = this.projectService.getAttrValue(attrName); List list = this.projectService.getAttrValue(attrName);
// String msg = "";
JSONArray arr = new JSONArray(); JSONArray arr = new JSONArray();
if ((list != null) || (!(list.isEmpty()))) if ((list != null) || (!(list.isEmpty())))
{ {
@ -213,10 +204,7 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
obj.put("isDefault", ((Map)list.get(i)).get("F_IS_DEFAULT")); obj.put("isDefault", ((Map)list.get(i)).get("F_IS_DEFAULT"));
arr.add(obj); arr.add(obj);
} }
// msg = arr.toString();
} }
// outputJson(res, msg);
return arr; return arr;
} }

View File

@ -398,6 +398,18 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">PCB板材</label>
<div class="col-sm-8">
<select name="pcbMaterial" class="form-control m-b" required>
</select>
</div>
</div>
</div>
</div>
</form> </form>
</div> </div>
@ -422,10 +434,10 @@
$("#form-project-add").validate({ $("#form-project-add").validate({
onkeyup: false, onkeyup: false,
rules:{ rules:{
projectName:{ // projectName:{
minlength: 6, // minlength: 6,
maxlength: 32, // maxlength: 32,
}, // },
boardThickness:{ boardThickness:{
number: true number: true
}, },
@ -437,10 +449,11 @@
}, },
maxHeightBot:{ maxHeightBot:{
number: true number: true
}, }
version:{ // ,
number: true // version:{
} // number: true
// }
}, },
focusCleanup: true focusCleanup: true
}); });
@ -742,6 +755,7 @@
$("select[name='directionBot']").val(data.directionBot).trigger("change"); $("select[name='directionBot']").val(data.directionBot).trigger("change");
$("select[name='directionBotFs']").val(data.directionBotFs).trigger("change"); $("select[name='directionBotFs']").val(data.directionBotFs).trigger("change");
$("select[name='density']").val(data.density).trigger("change"); $("select[name='density']").val(data.density).trigger("change");
$("select[name='pcbMaterial']").val(data.pcbMaterial).trigger("change");
} }
/** /**

View File

@ -4,8 +4,8 @@
<th:block th:include="include :: header('DOE分析')" /> <th:block th:include="include :: header('DOE分析')" />
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div class="container-div"> <div class="container-div" style="overflow: hidden">
<div class="row" style="height: 50%;"> <div class="row" style="height: 80%;">
<div class="col-sm-12 search-collapse"> <div class="col-sm-12 search-collapse">
<form id="search-form"> <form id="search-form">
<div class="select-list"> <div class="select-list">
@ -31,16 +31,16 @@
</form> </form>
</div> </div>
<div id="search-result-div1" class="col-sm-12 select-table table-striped" style="overflow: scroll;height:90%;"> <div id="search-result-div1" class="col-sm-12 select-table table-striped" style="height:90%;">
<table id="search-result-keyparam-table" class="table table-striped table-fixed-header" data-filter-control="true" <table id="search-result-keyparam-table" class="table table-striped table-fixed-header" data-filter-control="true"
data-filter-show-clear="true" ></table> data-filter-show-clear="true" ></table>
</div> </div>
<div id="search-result-div2" class="col-sm-12 select-table table-striped" style="overflow: scroll;height:90%; display: none;"> <div id="search-result-div2" class="col-sm-12 select-table table-striped" style="height:90%; display: none;">
<table id="search-result-rework-table" class="table table-striped table-fixed-header" data-filter-control="true" <table id="search-result-rework-table" class="table table-striped table-fixed-header" data-filter-control="true"
data-filter-show-clear="true"></table> data-filter-show-clear="true"></table>
</div> </div>
</div> </div>
<div class="row" style="height: 50%;"> <div class="row" style="height: 20%;">
<div class="col-sm-12 search-collapse"> <div class="col-sm-12 search-collapse">
<form id="calculate-form"> <form id="calculate-form">
<div class="select-list"> <div class="select-list">
@ -113,7 +113,10 @@
title: '规则名', title: '规则名',
sortable: false, sortable: false,
filterControl: 'select', filterControl: 'select',
filterStrictSearch: true filterStrictSearch: true,
formatter: function(value, row, index) {
return $.table.tooltip(row.keyparamdesc);
}
}, },
{ {
field: 'refdes', field: 'refdes',
@ -170,6 +173,13 @@
sortable: false, sortable: false,
filterControl: 'select', filterControl: 'select',
filterStrictSearch: true filterStrictSearch: true
},
{
field: 'boardbarcode',
title: '单板条码',
sortable: false,
filterControl: 'select',
filterStrictSearch: true
} }
] ]
}; };
@ -205,6 +215,13 @@
return index + 1; return index + 1;
} }
}, },
{
field: 'boardbarcode',
title: '单板条码',
sortable: false,
filterControl: 'select',
filterStrictSearch: true
},
{ {
field: 'refdes', field: 'refdes',
title: '位号', title: '位号',
@ -231,7 +248,10 @@
title: '规则名', title: '规则名',
sortable: false, sortable: false,
filterControl: 'select', filterControl: 'select',
filterStrictSearch: true filterStrictSearch: true,
formatter: function(value, row, index) {
return $.table.tooltip(row.keyparamdesc);
}
}, },
{ {
field: 'measurementvalue', field: 'measurementvalue',
@ -328,50 +348,6 @@
body: JSON.stringify(newData) body: JSON.stringify(newData)
}; };
// var arr = [{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"LX(连锡)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"9",
// "Defecttype":"LX(连锡)"
// },{
// "Keyparamtype":"9",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"9",
// "Defecttype":"JH(假焊)"
// },{
// "Keyparamtype":"7",
// "Defecttype":"LX(连锡)"
// }];
//
// var param = {
// quantity: 10000,
// productname : '130000161095AJB',
// version: '160500',
// body: JSON.stringify(arr)
// };
$.ajax({ $.ajax({
url: prefix + "/calculate", url: prefix + "/calculate",
data: param, data: param,

View File

@ -26,11 +26,11 @@ public class ProjectDAO extends JdbcBaseDao
public void add(Project project) public void add(Project project)
{ {
String sql = "INSERT INTO T_PROJECT (F_PROJECT_NAME ,F_VERSION, F_PCB_FILE,F_BOM_FILE,F_CHECK_TYPE,F_DFM_CHECK,F_PCB_TYPE,F_HDI_Model ,F_Board_Thickness, F_Panel_Model,F_Max_Heigh_Top,F_SubPCB_Num,F_Max_Heigh_Bot ,F_Railway_Position, F_Viacap_layer,F_Assembly_Process_Top,F_Have_Pb ,F_Assembly_Process_Bot, F_Surface_Process,F_Direction_Top,F_Primary_Side,F_Direction_Bot, F_Direction_Bot_Fs ,F_Density,F_SUBMIT_USER, F_SUBMIT_TIME,F_STATE,F_PRI ,F_FILE_RESULT, F_SERVER,F_PCB_FILE_NAME,F_BOM_FILE_NAME,F_SUBMIT_USERNAME,F_REPORT_LANGUAGE,F_CC_USERNAME)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; String sql = "INSERT INTO T_PROJECT (F_PROJECT_NAME ,F_VERSION, F_PCB_FILE,F_BOM_FILE,F_CHECK_TYPE,F_DFM_CHECK,F_PCB_TYPE,F_HDI_Model ,F_Board_Thickness, F_Panel_Model,F_Max_Heigh_Top,F_SubPCB_Num,F_Max_Heigh_Bot ,F_Railway_Position, F_Viacap_layer,F_Assembly_Process_Top,F_Have_Pb ,F_Assembly_Process_Bot, F_Surface_Process,F_Direction_Top,F_Primary_Side,F_Direction_Bot, F_Direction_Bot_Fs ,F_Density,F_SUBMIT_USER, F_SUBMIT_TIME,F_STATE,F_PRI ,F_FILE_RESULT, F_SERVER,F_PCB_FILE_NAME,F_BOM_FILE_NAME,F_SUBMIT_USERNAME,F_REPORT_LANGUAGE,F_CC_USERNAME, F_Pcb_Material)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
Object[] args = new Object[35]; Object[] args = new Object[36];
args[0] = project.getProjectName(); args[0] = project.getProjectName();
args[1] = Integer.valueOf(project.getVersion()); args[1] = project.getVersion();
args[2] = Integer.valueOf(project.getPcbFile()); args[2] = Integer.valueOf(project.getPcbFile());
args[3] = Integer.valueOf(project.getBomFile()); args[3] = Integer.valueOf(project.getBomFile());
args[4] = Integer.valueOf(project.getCheckType()); args[4] = Integer.valueOf(project.getCheckType());
@ -66,6 +66,7 @@ public class ProjectDAO extends JdbcBaseDao
args[32] = project.getSubmitUserName(); args[32] = project.getSubmitUserName();
args[33] = project.getReportLanguage(); args[33] = project.getReportLanguage();
args[34] = project.getCCtoOther(); args[34] = project.getCCtoOther();
args[35] = project.getPcbMaterial();
getJdbcTemplate().update(sql, args); getJdbcTemplate().update(sql, args);
} }
@ -177,7 +178,7 @@ public class ProjectDAO extends JdbcBaseDao
Project project = new Project(); Project project = new Project();
project.setId(Integer.parseInt(map.get("F_ID").toString())); project.setId(Integer.parseInt(map.get("F_ID").toString()));
project.setProjectName((map.get("F_PROJECT_NAME") == null) ? "" : map.get("F_PROJECT_NAME").toString()); project.setProjectName((map.get("F_PROJECT_NAME") == null) ? "" : map.get("F_PROJECT_NAME").toString());
project.setVersion((map.get("F_VERSION") == null) ? 0 : Integer.parseInt(map.get("F_VERSION").toString())); project.setVersion((String)map.get("F_VERSION"));
project.setPcbFile((map.get("F_PCB_FILE") == null) ? 0 : Integer.parseInt(map.get("F_PCB_FILE").toString())); project.setPcbFile((map.get("F_PCB_FILE") == null) ? 0 : Integer.parseInt(map.get("F_PCB_FILE").toString()));
project.setBomFile((map.get("F_BOM_FILE") == null) ? 0 : Integer.parseInt(map.get("F_BOM_FILE").toString())); project.setBomFile((map.get("F_BOM_FILE") == null) ? 0 : Integer.parseInt(map.get("F_BOM_FILE").toString()));
project.setCheckType((map.get("F_CHECK_TYPE") == null) ? 0 : Integer.parseInt(map.get("F_CHECK_TYPE").toString())); project.setCheckType((map.get("F_CHECK_TYPE") == null) ? 0 : Integer.parseInt(map.get("F_CHECK_TYPE").toString()));
@ -200,6 +201,7 @@ public class ProjectDAO extends JdbcBaseDao
project.setDirectionBot((map.get("F_Direction_Bot") == null) ? 0 : Integer.parseInt(map.get("F_Direction_Bot").toString())); project.setDirectionBot((map.get("F_Direction_Bot") == null) ? 0 : Integer.parseInt(map.get("F_Direction_Bot").toString()));
project.setDirectionBotFs((map.get("F_Direction_Bot_Fs") == null) ? 0 : Integer.parseInt(map.get("F_Direction_Bot_Fs").toString())); project.setDirectionBotFs((map.get("F_Direction_Bot_Fs") == null) ? 0 : Integer.parseInt(map.get("F_Direction_Bot_Fs").toString()));
project.setDensity((map.get("F_Density") == null) ? "" : map.get("F_Density").toString()); project.setDensity((map.get("F_Density") == null) ? "" : map.get("F_Density").toString());
project.setPcbMaterial((map.get("F_Pcb_Material") == null) ? 0 : Integer.parseInt(map.get("F_Pcb_Material").toString()));
project.setSubmitUser((map.get("F_SUBMIT_USER") == null) ? 0 : Integer.parseInt(map.get("F_SUBMIT_USER").toString())); project.setSubmitUser((map.get("F_SUBMIT_USER") == null) ? 0 : Integer.parseInt(map.get("F_SUBMIT_USER").toString()));
String submitTime = (map.get("F_SUBMIT_TIME") == null) ? "" : map.get("F_SUBMIT_TIME").toString(); String submitTime = (map.get("F_SUBMIT_TIME") == null) ? "" : map.get("F_SUBMIT_TIME").toString();
//project.setSubmitTime(); //project.setSubmitTime();
@ -660,4 +662,10 @@ public class ProjectDAO extends JdbcBaseDao
}); });
} }
public boolean checkProjectExists(String projectName, String version) {
String sql = "select count(1) from t_project where F_PROJECT_NAME = ? and F_VERSION = ?";
Integer exists = getJdbcTemplate().queryForObject(sql, new Object[]{projectName, version}, Integer.class);
return exists > 0;
}
} }

View File

@ -6,7 +6,7 @@ public class Project implements Serializable {
private static final long serialVersionUID = 6352252350113283745L; private static final long serialVersionUID = 6352252350113283745L;
private int id; private int id;
private String projectName; private String projectName;
private int version = 1; private String version = "";
private int pcbFile; private int pcbFile;
private int bomFile; private int bomFile;
private String pcbFileName; private String pcbFileName;
@ -32,6 +32,7 @@ public class Project implements Serializable {
private int directionBot; private int directionBot;
private int directionBotFs; private int directionBotFs;
private String density; private String density;
private int pcbMaterial;
private int submitUser; private int submitUser;
private String submitUserName; private String submitUserName;
private String submitTime; private String submitTime;
@ -93,11 +94,11 @@ public class Project implements Serializable {
this.projectName = projectName; this.projectName = projectName;
} }
public int getVersion() { public String getVersion() {
return this.version; return this.version;
} }
public void setVersion(int version) { public void setVersion(String version) {
this.version = version; this.version = version;
} }
@ -468,4 +469,12 @@ public class Project implements Serializable {
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark; this.remark = remark;
} }
public int getPcbMaterial() {
return pcbMaterial;
}
public void setPcbMaterial(int pcbMaterial) {
this.pcbMaterial = pcbMaterial;
}
} }

View File

@ -78,19 +78,14 @@ public class FileService {
log.error("创建项目文件目录失败"); log.error("创建项目文件目录失败");
throw new IOException(); throw new IOException();
} }
// Iterator<String> it = request.getFileNames();
// MultipartFile[] fileArr = new MultipartFile[]{pcbFile, bomFile};
FileInfo fileInfo; FileInfo fileInfo;
// while (it.hasNext()) {
for(MultipartFile multipartFile : multipartFiles) { for(MultipartFile multipartFile : multipartFiles) {
if(null == multipartFile) { if(null == multipartFile) {
continue; continue;
} }
// 表单file元素name属性值 // 表单file元素name属性值
// String name = it.next();
String name = multipartFile.getName(); String name = multipartFile.getName();
// 原文件名值 // 原文件名值
// MultipartFile multipartFile = request.getFile(name);
String original = multipartFile.getOriginalFilename(); String original = multipartFile.getOriginalFilename();
if(null == original || "".equals(original)) if(null == original || "".equals(original))
{ {
@ -129,7 +124,6 @@ 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(loginUser.getId()); fileInfo.setUploadUser(loginUser.getId());
// 设置实际名称 // 设置实际名称
String extendName = original.substring(original.lastIndexOf(".") + 1); String extendName = original.substring(original.lastIndexOf(".") + 1);

View File

@ -7,6 +7,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.dao.DuplicateKeyException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -35,11 +36,13 @@ public class ProjectService
{ {
try try
{ {
// String dir = ((UserInfo)req.getSession().getAttribute("user")).getUsername() + "/" + //检查 projectName + version 是否存在
// project.getProjectName() + "/" + "Ver" + project.getVersion(); boolean exists = checkProjectExists(project.getProjectName(), project.getVersion());
String dir = loginUser.getUsername() + "/" + if(exists) {
project.getProjectName() + "/" + "Ver" + project.getVersion(); throw new DuplicateKeyException("项目名和版本已存在");
}
String dir = loginUser.getUsername() + "/" + project.getProjectName() + "/" + "Ver" + project.getVersion();
MultipartFile[] multipartFiles = new MultipartFile[]{pcbFile, bomFile}; MultipartFile[] multipartFiles = new MultipartFile[]{pcbFile, bomFile};
List fileList = new ArrayList(); List fileList = new ArrayList();
this.fileService.savePhysicFile(loginUser, multipartFiles, fileList, dir, false , null); this.fileService.savePhysicFile(loginUser, multipartFiles, fileList, dir, false , null);
@ -62,21 +65,24 @@ public class ProjectService
this.projectDAO.add(project); this.projectDAO.add(project);
createParamFile(dir, project); createParamFile(dir, project);
reOrderPriByState("待查", project.getPri()); reOrderPriByState("待查", project.getPri());
} catch (IOException e) { } catch (Exception e) {
logger.error("创建文件失败!", e); logger.error("创建文件失败!", e);
throw e; throw e;
} }
} }
private boolean checkProjectExists(String projectName, String version) {
return this.projectDAO.checkProjectExists(projectName, version);
}
private void createParamFile(String dir, Project project) private void createParamFile(String dir, Project project)
throws IOException throws IOException
{ {
String fileName = project.getProjectName() + "_" + project.getVersion() + ".param"; String fileName = project.getProjectName() + "_" + project.getVersion() + ".param";
File file = this.fileService.createFile(dir + "/" + fileName); File file = this.fileService.createFile(dir + "/" + fileName);
int[] ids = new int[15]; int[] ids = new int[16];
ids[0] = project.getCheckType(); ids[0] = project.getCheckType();
ids[1] = project.getPcbType(); ids[1] = project.getPcbType();
ids[2] = project.getHdiModel(); ids[2] = project.getHdiModel();
@ -92,12 +98,12 @@ public class ProjectService
ids[12] = project.getDirectionBot(); ids[12] = project.getDirectionBot();
ids[13] = project.getDirectionBotFs(); ids[13] = project.getDirectionBotFs();
ids[14] = Integer.parseInt(project.getDensity()); ids[14] = Integer.parseInt(project.getDensity());
ids[15] = project.getPcbMaterial();
List<Map<String, Object>> attrValues = this.projectDAO.getAttrValueByIds(ids); List<Map<String, Object>> attrValues = this.projectDAO.getAttrValueByIds(ids);
UserInfo userInfo = this.userDAO.getById(project.getSubmitUser()); UserInfo userInfo = this.userDAO.getById(project.getSubmitUser());
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("User=" + project.getSubmitUserName()); sb.append("User=" + project.getSubmitUserName());
@ -209,6 +215,8 @@ public class ProjectService
sb.append("\r\n"); sb.append("\r\n");
sb.append("Direction_Bot=" + getValueById(attrValues, project.getDirectionBot())); sb.append("Direction_Bot=" + getValueById(attrValues, project.getDirectionBot()));
sb.append("\r\n"); sb.append("\r\n");
sb.append("Pcb_Material=" + getValueById(attrValues, project.getPcbMaterial()));
sb.append("\r\n");
sb.append("Density=" + getValueById(attrValues, Integer.parseInt(project.getDensity()))); sb.append("Density=" + getValueById(attrValues, Integer.parseInt(project.getDensity())));
OutputStream os = new FileOutputStream(file); OutputStream os = new FileOutputStream(file);
os.write(sb.toString().getBytes()); os.write(sb.toString().getBytes());
@ -331,8 +339,7 @@ public class ProjectService
file.delete(); file.delete();
} }
if ((project.getVersion() > 1) || if (!(file.getParentFile().exists()))
(!(file.getParentFile().exists())))
continue; continue;
file.getParentFile().delete(); file.getParentFile().delete();
} }