diff --git a/src/main/java/com/xkrs/controller/FileController.java b/src/main/java/com/xkrs/controller/FileController.java index 36f5e1b..bfe69af 100644 --- a/src/main/java/com/xkrs/controller/FileController.java +++ b/src/main/java/com/xkrs/controller/FileController.java @@ -3,7 +3,6 @@ package com.xkrs.controller; import com.xkrs.dao.FileDao; import com.xkrs.encapsulation.PromptMessageEnum; import com.xkrs.model.qo.FileQo; -import com.xkrs.model.qo.FileUpdateQo; import com.xkrs.service.FileService; import com.xkrs.util.ExcelUploadUtil; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; @@ -50,20 +49,20 @@ public class FileController { /** * 修改上传的模板信息 * - * @param fileUpdateQo + * @param fileQo * @param fileExcel * @return * @throws IOException */ @PostMapping("/updateFileUploadPath") @Transactional(rollbackOn = Exception.class) - public String updateFileUploadPath(@RequestBody FileUpdateQo fileUpdateQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException { - String lotNo = fileUpdateQo.getLotNo(); - String machineNo = fileUpdateQo.getMachineNo(); - String materialNo = fileUpdateQo.getMaterialNo(); - String modelNo = fileUpdateQo.getModelNo(); - String machineTypeNo = fileUpdateQo.getMachineTypeNo(); - String craftItemName = fileUpdateQo.getCraftItemName(); + public String updateFileUploadPath(@RequestBody FileQo fileQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException { + String lotNo = fileQo.getLotNo(); + String machineNo = fileQo.getMachineNo(); + String materialNo = fileQo.getMaterialNo(); + String modelNo = fileQo.getModelNo(); + String machineTypeNo = fileQo.getMachineTypeNo(); + String craftItemName = fileQo.getCraftItemName(); Locale locale = LocaleContextHolder.getLocale(); String file = ExcelUploadUtil.memoryFile(fileExcel, 1); fileDao.updateFileUploadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, file); diff --git a/src/main/java/com/xkrs/model/qo/FileQo.java b/src/main/java/com/xkrs/model/qo/FileQo.java index da63156..08acc61 100644 --- a/src/main/java/com/xkrs/model/qo/FileQo.java +++ b/src/main/java/com/xkrs/model/qo/FileQo.java @@ -46,12 +46,6 @@ public class FileQo { @NotBlank(message = "{FileEntity.craftItemName.blank}", groups = {FileQoInsert.class}) private String craftItemName; - /** - * 上传模板的路径 - */ - @NotBlank(message = "{FileEntity.fileUploadPath.blank}", groups = {FileQoInsert.class}) - private String fileUploadPath; - public FileQo() { } @@ -102,12 +96,4 @@ public class FileQo { public void setCraftItemName(String craftItemName) { this.craftItemName = craftItemName; } - - public String getFileUploadPath() { - return fileUploadPath; - } - - public void setFileUploadPath(String fileUploadPath) { - this.fileUploadPath = fileUploadPath; - } } diff --git a/src/main/java/com/xkrs/model/qo/FileUpdateQo.java b/src/main/java/com/xkrs/model/qo/FileUpdateQo.java deleted file mode 100644 index 6ee00c9..0000000 --- a/src/main/java/com/xkrs/model/qo/FileUpdateQo.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.xkrs.model.qo; - - -import com.xkrs.model.validation.FileQoInsert; -import com.xkrs.model.validation.FileUpdateQoUpdate; - -import javax.validation.constraints.NotBlank; - -/** - * @Author: XinYi Song - * @Date: 2022/1/20 16:20 - */ -public class FileUpdateQo { - - /** - * 批次号 - */ - @NotBlank(message = "{FileEntity.lotNo.blank}", groups = {FileUpdateQoUpdate.class}) - private String lotNo; - - /** - * 机器号 - */ - @NotBlank(message = "{FileEntity.machineNo.blank}", groups = {FileUpdateQoUpdate.class}) - private String machineNo; - - /** - * 物料号 - */ - @NotBlank(message = "{FileEntity.materialNo.blank}", groups = {FileUpdateQoUpdate.class}) - private String materialNo; - - /** - * 模具号 - */ - @NotBlank(message = "{FileEntity.modelNo.blank}", groups = {FileUpdateQoUpdate.class}) - private String modelNo; - - /** - * 机种号 - */ - @NotBlank(message = "{FileEntity.machineTypeNo.blank}", groups = {FileUpdateQoUpdate.class}) - private String machineTypeNo; - - /** - * 工艺项目名称 - */ - @NotBlank(message = "{FileEntity.craftItemName.blank}", groups = {FileQoInsert.class}) - private String craftItemName; - - public FileUpdateQo() { - } - - public String getLotNo() { - return lotNo; - } - - public void setLotNo(String lotNo) { - this.lotNo = lotNo; - } - - public String getMachineNo() { - return machineNo; - } - - public void setMachineNo(String machineNo) { - this.machineNo = machineNo; - } - - public String getMaterialNo() { - return materialNo; - } - - public void setMaterialNo(String materialNo) { - this.materialNo = materialNo; - } - - public String getModelNo() { - return modelNo; - } - - public void setModelNo(String modelNo) { - this.modelNo = modelNo; - } - - public String getMachineTypeNo() { - return machineTypeNo; - } - - public void setMachineTypeNo(String machineTypeNo) { - this.machineTypeNo = machineTypeNo; - } - - public String getCraftItemName() { - return craftItemName; - } - - public void setCraftItemName(String craftItemName) { - this.craftItemName = craftItemName; - } -} diff --git a/src/main/java/com/xkrs/util/ExcelUploadUtil.java b/src/main/java/com/xkrs/util/ExcelUploadUtil.java index 7f4afb7..8db6ee8 100644 --- a/src/main/java/com/xkrs/util/ExcelUploadUtil.java +++ b/src/main/java/com/xkrs/util/ExcelUploadUtil.java @@ -29,10 +29,7 @@ public class ExcelUploadUtil { * @throws IOException */ public static String memoryFile(MultipartFile fileInput, int subDirType) throws IOException { - String subDir = subDirType == 1 ? "/excel/" : "/picture/"; - //String uploadPath = "http://139.199.98.175:2088/wfTaskImage/"; -// String uploadPath = "http://192.168.2.9:2088/"; - String uploadPath = "http://118.24.27.47:4096/"; + String subDir = subDirType == 1 ? "excel/" : "picture/"; //获取原始文件名 String originalFilename = fileInput.getOriginalFilename(); if (originalFilename != null && !"".equals(originalFilename)) { @@ -42,19 +39,14 @@ public class ExcelUploadUtil { String suffix = originalFilename.substring(index); //uuid生成新的文件名 String newName = UUID.randomUUID().toString() + suffix; - - //将图片保存到本地/usr/etc/images/Folder - File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir); -// File file = new File("/home/sxy/server/industrial_measurement" + subDir); + File file = new File("/home/sxy/server/industrial_measurement/" + subDir); if (!file.exists()) { file.mkdirs(); } - String path = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + newName; -// String path = "/home/sxy/server/industrial_measurement" + subDir + newName; - String uploadsImage = uploadPath + newName; + String path = "/home/sxy/server/industrial_measurement/" + subDir + newName; //实现上传 fileInput.transferTo(new File(path)); - return subDir + newName; + return "http://118.24.27.47:2088/" + subDir + newName; } return null; }