diff --git a/doc/工作计划 b/doc/工作计划 index 2d6ea0b12..7c7b6cdf9 100644 --- a/doc/工作计划 +++ b/doc/工作计划 @@ -7,3 +7,20 @@ 实际: 1.完成菜单移植 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 \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/ProjectController.java b/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/ProjectController.java index fedfcae29..b261898c8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/ProjectController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/ProjectController.java @@ -14,11 +14,11 @@ import com.ruoyi.dfm.service.UserService; import com.ruoyi.dfm.util.TimeUtil; import com.ruoyi.framework.util.ShiroUtils; import org.apache.commons.lang.StringUtils; -import org.aspectj.weaver.loadtime.Aj; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; 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) throws Exception { + + String projectName = req.getParameter("projectName"); + String version = req.getParameter("version").trim(); + try { - //FIXME 修改上传文件 -// MultipartResolver cmr = null;//new CosMultipartResolver(request.getSession().getServletContext()); - -// MultipartHttpServletRequest req = cmr.resolveMultipart(request); - - String projectName = req.getParameter("projectName"); +// String projectName = req.getParameter("projectName"); String[] dfmCheckArr = req.getParameterValues("dfmCheck"); String dfmCheck = ""; if (dfmCheckArr != null) @@ -86,7 +85,8 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont 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 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()); @@ -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 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 pcbMaterial = (req.getParameter("pcbMaterial").trim() == "") ? 0 : Integer.parseInt(req.getParameter("pcbMaterial").trim()); String density = req.getParameter("density"); 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.setDirectionBotFs(directionBotFs); project.setDensity(density); + project.setPcbMaterial(pcbMaterial); project.setLastVersion(lastVersion); project.setReportLanguage(reportLanguage); @@ -160,17 +162,15 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont ccEmail = userCC + ";" + CCtoOther; } } - project.setCCtoOther(ccEmail); this.projectService.addProject(ShiroUtils.getLoginUser(), pcbFile, bomFile, project); -// outputMsg(res, ""); -// return null; 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); -// outputMsg(res, ""); } -//// return null; return AjaxResult.error(); } } @@ -184,14 +184,6 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont String projectName = req.getParameter("projectName"); Project project = this.projectService.getLastVersion(uid, projectName); return project; -// String msg = ""; -// if (project != null) -// { -// //msg = JSONObject.fromObject(project).toString(); -// msg = JSON.toJSONString(project); -// } -// -// outputJson(res, msg); } @RequestMapping("/getAttrValue") @@ -200,7 +192,6 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont { String attrName = req.getParameter("attrName"); List list = this.projectService.getAttrValue(attrName); -// String msg = ""; JSONArray arr = new JSONArray(); 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")); arr.add(obj); } -// msg = arr.toString(); } - -// outputJson(res, msg); return arr; } diff --git a/ruoyi-admin/src/main/resources/templates/dfm/addProject.html b/ruoyi-admin/src/main/resources/templates/dfm/addProject.html index c047bc377..135e1fabc 100644 --- a/ruoyi-admin/src/main/resources/templates/dfm/addProject.html +++ b/ruoyi-admin/src/main/resources/templates/dfm/addProject.html @@ -398,6 +398,18 @@ +
+
+
+ +
+ +
+
+
+
+ @@ -422,10 +434,10 @@ $("#form-project-add").validate({ onkeyup: false, rules:{ - projectName:{ - minlength: 6, - maxlength: 32, - }, + // projectName:{ + // minlength: 6, + // maxlength: 32, + // }, boardThickness:{ number: true }, @@ -437,10 +449,11 @@ }, maxHeightBot:{ number: true - }, - version:{ - number: true - } + } + // , + // version:{ + // number: true + // } }, focusCleanup: true }); @@ -742,6 +755,7 @@ $("select[name='directionBot']").val(data.directionBot).trigger("change"); $("select[name='directionBotFs']").val(data.directionBotFs).trigger("change"); $("select[name='density']").val(data.density).trigger("change"); + $("select[name='pcbMaterial']").val(data.pcbMaterial).trigger("change"); } /** diff --git a/ruoyi-admin/src/main/resources/templates/dfm/doeAnalysis.html b/ruoyi-admin/src/main/resources/templates/dfm/doeAnalysis.html index 3a5be7cde..4d9cadaf4 100644 --- a/ruoyi-admin/src/main/resources/templates/dfm/doeAnalysis.html +++ b/ruoyi-admin/src/main/resources/templates/dfm/doeAnalysis.html @@ -4,8 +4,8 @@ -
-
+
+
@@ -31,16 +31,16 @@
-
+
- -
+
@@ -113,7 +113,10 @@ title: '规则名', sortable: false, filterControl: 'select', - filterStrictSearch: true + filterStrictSearch: true, + formatter: function(value, row, index) { + return $.table.tooltip(row.keyparamdesc); + } }, { field: 'refdes', @@ -170,6 +173,13 @@ sortable: false, filterControl: 'select', filterStrictSearch: true + }, + { + field: 'boardbarcode', + title: '单板条码', + sortable: false, + filterControl: 'select', + filterStrictSearch: true } ] }; @@ -205,6 +215,13 @@ return index + 1; } }, + { + field: 'boardbarcode', + title: '单板条码', + sortable: false, + filterControl: 'select', + filterStrictSearch: true + }, { field: 'refdes', title: '位号', @@ -231,7 +248,10 @@ title: '规则名', sortable: false, filterControl: 'select', - filterStrictSearch: true + filterStrictSearch: true, + formatter: function(value, row, index) { + return $.table.tooltip(row.keyparamdesc); + } }, { field: 'measurementvalue', @@ -328,50 +348,6 @@ 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({ url: prefix + "/calculate", data: param, diff --git a/ruoyi-system/src/main/java/com/ruoyi/dfm/dao/ProjectDAO.java b/ruoyi-system/src/main/java/com/ruoyi/dfm/dao/ProjectDAO.java index 8fd26eadf..84e8902c2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/dfm/dao/ProjectDAO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/dfm/dao/ProjectDAO.java @@ -26,11 +26,11 @@ public class ProjectDAO extends JdbcBaseDao 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[1] = Integer.valueOf(project.getVersion()); + args[1] = project.getVersion(); args[2] = Integer.valueOf(project.getPcbFile()); args[3] = Integer.valueOf(project.getBomFile()); args[4] = Integer.valueOf(project.getCheckType()); @@ -66,6 +66,7 @@ public class ProjectDAO extends JdbcBaseDao args[32] = project.getSubmitUserName(); args[33] = project.getReportLanguage(); args[34] = project.getCCtoOther(); + args[35] = project.getPcbMaterial(); getJdbcTemplate().update(sql, args); } @@ -177,7 +178,7 @@ public class ProjectDAO extends JdbcBaseDao Project project = new Project(); project.setId(Integer.parseInt(map.get("F_ID").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.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())); @@ -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.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.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())); String submitTime = (map.get("F_SUBMIT_TIME") == null) ? "" : map.get("F_SUBMIT_TIME").toString(); //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; + } + } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/dfm/pojo/Project.java b/ruoyi-system/src/main/java/com/ruoyi/dfm/pojo/Project.java index 016ba7b27..ecd9f2d05 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/dfm/pojo/Project.java +++ b/ruoyi-system/src/main/java/com/ruoyi/dfm/pojo/Project.java @@ -6,7 +6,7 @@ public class Project implements Serializable { private static final long serialVersionUID = 6352252350113283745L; private int id; private String projectName; - private int version = 1; + private String version = ""; private int pcbFile; private int bomFile; private String pcbFileName; @@ -32,6 +32,7 @@ public class Project implements Serializable { private int directionBot; private int directionBotFs; private String density; + private int pcbMaterial; private int submitUser; private String submitUserName; private String submitTime; @@ -93,11 +94,11 @@ public class Project implements Serializable { this.projectName = projectName; } - public int getVersion() { + public String getVersion() { return this.version; } - public void setVersion(int version) { + public void setVersion(String version) { this.version = version; } @@ -468,4 +469,12 @@ public class Project implements Serializable { public void setRemark(String remark) { this.remark = remark; } + + public int getPcbMaterial() { + return pcbMaterial; + } + + public void setPcbMaterial(int pcbMaterial) { + this.pcbMaterial = pcbMaterial; + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/dfm/service/FileService.java b/ruoyi-system/src/main/java/com/ruoyi/dfm/service/FileService.java index 26706b16b..c5470ffac 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/dfm/service/FileService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/dfm/service/FileService.java @@ -78,19 +78,14 @@ public class FileService { log.error("创建项目文件目录失败"); throw new IOException(); } -// Iterator it = request.getFileNames(); -// MultipartFile[] fileArr = new MultipartFile[]{pcbFile, bomFile}; FileInfo fileInfo; -// while (it.hasNext()) { for(MultipartFile multipartFile : multipartFiles) { if(null == multipartFile) { continue; } // 表单file元素name属性值 -// String name = it.next(); String name = multipartFile.getName(); // 原文件名值 -// MultipartFile multipartFile = request.getFile(name); String original = multipartFile.getOriginalFilename(); if(null == original || "".equals(original)) { @@ -129,7 +124,6 @@ public class FileService { fileInfo.setFileSize(multipartFile.getSize()); fileInfo.setRelaPath(filePath); fileInfo.setUploadTime(TimeUtil.getNowChar14()); -// fileInfo.setUploadUser(((UserInfo)request.getSession().getAttribute("user")).getId()); fileInfo.setUploadUser(loginUser.getId()); // 设置实际名称 String extendName = original.substring(original.lastIndexOf(".") + 1); diff --git a/ruoyi-system/src/main/java/com/ruoyi/dfm/service/ProjectService.java b/ruoyi-system/src/main/java/com/ruoyi/dfm/service/ProjectService.java index 0475f3c5c..628e874e6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/dfm/service/ProjectService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/dfm/service/ProjectService.java @@ -7,6 +7,7 @@ import com.ruoyi.dfm.util.TimeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @@ -35,11 +36,13 @@ public class ProjectService { try { -// String dir = ((UserInfo)req.getSession().getAttribute("user")).getUsername() + "/" + -// project.getProjectName() + "/" + "Ver" + project.getVersion(); - String dir = loginUser.getUsername() + "/" + - project.getProjectName() + "/" + "Ver" + project.getVersion(); + //检查 projectName + version 是否存在 + boolean exists = checkProjectExists(project.getProjectName(), project.getVersion()); + if(exists) { + throw new DuplicateKeyException("项目名和版本已存在"); + } + String dir = loginUser.getUsername() + "/" + project.getProjectName() + "/" + "Ver" + project.getVersion(); MultipartFile[] multipartFiles = new MultipartFile[]{pcbFile, bomFile}; List fileList = new ArrayList(); this.fileService.savePhysicFile(loginUser, multipartFiles, fileList, dir, false , null); @@ -62,21 +65,24 @@ public class ProjectService this.projectDAO.add(project); createParamFile(dir, project); - reOrderPriByState("待查", project.getPri()); - } catch (IOException e) { + } catch (Exception e) { logger.error("创建文件失败!", e); throw e; } } + private boolean checkProjectExists(String projectName, String version) { + return this.projectDAO.checkProjectExists(projectName, version); + } + private void createParamFile(String dir, Project project) throws IOException { String fileName = project.getProjectName() + "_" + project.getVersion() + ".param"; File file = this.fileService.createFile(dir + "/" + fileName); - int[] ids = new int[15]; + int[] ids = new int[16]; ids[0] = project.getCheckType(); ids[1] = project.getPcbType(); ids[2] = project.getHdiModel(); @@ -92,11 +98,11 @@ public class ProjectService ids[12] = project.getDirectionBot(); ids[13] = project.getDirectionBotFs(); ids[14] = Integer.parseInt(project.getDensity()); + ids[15] = project.getPcbMaterial(); List> attrValues = this.projectDAO.getAttrValueByIds(ids); UserInfo userInfo = this.userDAO.getById(project.getSubmitUser()); - StringBuilder sb = new StringBuilder(); @@ -209,6 +215,8 @@ public class ProjectService sb.append("\r\n"); sb.append("Direction_Bot=" + getValueById(attrValues, project.getDirectionBot())); 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()))); OutputStream os = new FileOutputStream(file); os.write(sb.toString().getBytes()); @@ -331,8 +339,7 @@ public class ProjectService file.delete(); } - if ((project.getVersion() > 1) || - (!(file.getParentFile().exists()))) + if (!(file.getParentFile().exists())) continue; file.getParentFile().delete(); }