更新参数类型
This commit is contained in:
parent
b0afd5f4aa
commit
266c46fe16
@ -59,7 +59,7 @@ public class FileController {
|
|||||||
@Transactional(rollbackOn = Exception.class)
|
@Transactional(rollbackOn = Exception.class)
|
||||||
public String updateFileUploadPath(@RequestBody FileUpdateQo fileUpdateQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException {
|
public String updateFileUploadPath(@RequestBody FileUpdateQo fileUpdateQo, @RequestParam("fileExcel") MultipartFile fileExcel) throws IOException {
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
String file = ExcelUploadUtil.memoryFile(fileExcel);
|
String file = ExcelUploadUtil.memoryFile(fileExcel,1);
|
||||||
fileDao.updateFileUploadPath(fileUpdateQo.getLotNo(), fileUpdateQo.getMachineNo(), fileUpdateQo.getMaterialNo(), fileUpdateQo.getModelNo(), fileUpdateQo.getPartNo(), file);
|
fileDao.updateFileUploadPath(fileUpdateQo.getLotNo(), fileUpdateQo.getMachineNo(), fileUpdateQo.getMaterialNo(), fileUpdateQo.getModelNo(), fileUpdateQo.getPartNo(), file);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功!", locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功!", locale);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.Modifying;
|
|||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,6 +40,6 @@ public interface PictureDao extends JpaRepository<PictureEntity, Long>, JpaSpeci
|
|||||||
* @param picturePath 图片路径
|
* @param picturePath 图片路径
|
||||||
*/
|
*/
|
||||||
@Modifying(clearAutomatically = true)
|
@Modifying(clearAutomatically = true)
|
||||||
@Query(value = "UPDATE qc_inspection_picture SET picture_path = ?6 where lot_no = ?1 and machine_no = ?2 and material_no = ?3 and model_no = ?4 and part_no = ?5",nativeQuery = true)
|
@Query(value = "UPDATE qc_inspection_picture SET picture_path = ?6 where lot_no = ?1 and machine_no = ?2 and material_no = ?3 and model_no = ?4 and part_no = ?5", nativeQuery = true)
|
||||||
void updatePicturePath(String lotNo, String machineNo, String materialNo, String modelNo, String partNo, String picturePath);
|
void updatePicturePath(String lotNo, String machineNo, String materialNo, String modelNo, String partNo, String picturePath);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class FileServiceImpl implements FileService {
|
|||||||
if (fileExcel == null) {
|
if (fileExcel == null) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "模板不能为空!", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "模板不能为空!", locale);
|
||||||
}
|
}
|
||||||
String file = ExcelUploadUtil.memoryFile(fileExcel);
|
String file = ExcelUploadUtil.memoryFile(fileExcel,1);
|
||||||
FileEntity fileEntity1 = new FileEntity();
|
FileEntity fileEntity1 = new FileEntity();
|
||||||
fileEntity1.setLotNo(fileQo.getLotNo());
|
fileEntity1.setLotNo(fileQo.getLotNo());
|
||||||
fileEntity1.setMachineNo(fileQo.getMachineNo());
|
fileEntity1.setMachineNo(fileQo.getMachineNo());
|
||||||
|
@ -35,7 +35,7 @@ public class PictureServiceImpl implements PictureService {
|
|||||||
if (pictureEntity2.isPresent()) {
|
if (pictureEntity2.isPresent()) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "请勿重复添加!", locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT, "请勿重复添加!", locale);
|
||||||
}
|
}
|
||||||
String file = ExcelUploadUtil.memoryFile(pictureFile);
|
String file = ExcelUploadUtil.memoryFile(pictureFile, 2);
|
||||||
PictureEntity pictureEntity1 = new PictureEntity();
|
PictureEntity pictureEntity1 = new PictureEntity();
|
||||||
pictureEntity1.setLotNo(lotNo);
|
pictureEntity1.setLotNo(lotNo);
|
||||||
pictureEntity1.setMachineNo(machineNo);
|
pictureEntity1.setMachineNo(machineNo);
|
||||||
|
@ -23,16 +23,18 @@ public class ExcelUploadUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传单张图片
|
* 上传单张图片
|
||||||
* @param fileExcel
|
*
|
||||||
|
* @param fileInput
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static String memoryFile(MultipartFile fileExcel) 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://139.199.98.175:2088/wfTaskImage/";
|
||||||
// String uploadPath = "http://192.168.2.9:2088/";
|
// String uploadPath = "http://192.168.2.9:2088/";
|
||||||
String uploadPath = "http://118.24.27.47:4096/";
|
String uploadPath = "http://118.24.27.47:4096/";
|
||||||
//获取原始文件名
|
//获取原始文件名
|
||||||
String originalFilename = fileExcel.getOriginalFilename();
|
String originalFilename = fileInput.getOriginalFilename();
|
||||||
if (originalFilename != null && !"".equals(originalFilename)) {
|
if (originalFilename != null && !"".equals(originalFilename)) {
|
||||||
//找到 . 的位置
|
//找到 . 的位置
|
||||||
int index = originalFilename.lastIndexOf(".");
|
int index = originalFilename.lastIndexOf(".");
|
||||||
@ -42,16 +44,16 @@ public class ExcelUploadUtil {
|
|||||||
String newName = UUID.randomUUID().toString() + suffix;
|
String newName = UUID.randomUUID().toString() + suffix;
|
||||||
|
|
||||||
//将图片保存到本地/usr/etc/images/Folder
|
//将图片保存到本地/usr/etc/images/Folder
|
||||||
//File file = new File("E:/shoptest/");
|
// File file = new File("/Users/liuchengqian/Desktop/DaJiang/");
|
||||||
File file = new File("/home/sxy/server/industrial_measurement/excel/");
|
File file = new File("/home/sxy/server/industrial_measurement/" + subDir);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
}
|
}
|
||||||
//String path = "E:/shoptest/" + newName;
|
// String path = "/Users/liuchengqian/Desktop/DaJiang/"+newName;
|
||||||
String path = "/home/sxy/server/industrial_measurement/excel/" + newName;
|
String path = "/home/sxy/server/industrial_measurement/" + subDir + newName;
|
||||||
String uploadsImage = uploadPath + newName;
|
String uploadsImage = uploadPath + newName;
|
||||||
//实现上传
|
//实现上传
|
||||||
fileExcel.transferTo(new File(path));
|
fileInput.transferTo(new File(path));
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -99,27 +101,27 @@ public class ExcelUploadUtil {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除本地或服务器储存的图片
|
* 删除本地或服务器储存的图片
|
||||||
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String delFile(String path){
|
public static String delFile(String path) {
|
||||||
String resultInfo = null;
|
String resultInfo = null;
|
||||||
int lastIndexOf = path.lastIndexOf("/");
|
int lastIndexOf = path.lastIndexOf("/");
|
||||||
String imgPath = path.substring(lastIndexOf + 1,path.length());
|
String imgPath = path.substring(lastIndexOf + 1, path.length());
|
||||||
System.out.println(imgPath);
|
System.out.println(imgPath);
|
||||||
imgPath = "/usr/local/etc/images/" + imgPath;
|
imgPath = "/usr/local/etc/images/" + imgPath;
|
||||||
// img_path = "/usr/etc/images/Folder/" + img_path;
|
// img_path = "/usr/etc/images/Folder/" + img_path;
|
||||||
File file = new File(imgPath);
|
File file = new File(imgPath);
|
||||||
if(file.exists()){
|
if (file.exists()) {
|
||||||
if(file.delete()){
|
if (file.delete()) {
|
||||||
resultInfo = "删除成功!";
|
resultInfo = "删除成功!";
|
||||||
}else {
|
} else {
|
||||||
resultInfo = "删除失败!";
|
resultInfo = "删除失败!";
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
resultInfo = "文件不存在";
|
resultInfo = "文件不存在";
|
||||||
}
|
}
|
||||||
return resultInfo;
|
return resultInfo;
|
||||||
@ -127,6 +129,7 @@ public class ExcelUploadUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过图片路径解析 ,上传保存
|
* 通过图片路径解析 ,上传保存
|
||||||
|
*
|
||||||
* @param listImgSrc
|
* @param listImgSrc
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -171,17 +174,18 @@ public class ExcelUploadUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除本地文件夹图片
|
* 删除本地文件夹图片
|
||||||
|
*
|
||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
public static void deleteImage(String url){
|
public static void deleteImage(String url) {
|
||||||
File file=new File(url);
|
File file = new File(url);
|
||||||
//判断file是否是文件目录 若是返回TRUE
|
//判断file是否是文件目录 若是返回TRUE
|
||||||
if (file.isDirectory()){
|
if (file.isDirectory()) {
|
||||||
//name存储file文件夹中的文件名
|
//name存储file文件夹中的文件名
|
||||||
String[] name =file.list();
|
String[] name = file.list();
|
||||||
for (int i=0; i<name.length; i++){
|
for (int i = 0; i < name.length; i++) {
|
||||||
//此时就可得到文件夹中的文件
|
//此时就可得到文件夹中的文件
|
||||||
File f=new File(url, name[i]);
|
File f = new File(url, name[i]);
|
||||||
//删除文件
|
//删除文件
|
||||||
f.delete();
|
f.delete();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user