Commit 23d84aa6 authored by zhengjiawei's avatar zhengjiawei

bug

parent 21f61eda
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PreplanPicture; import com.yeejoin.amos.fas.dao.entity.PreplanPicture;
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.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
...@@ -11,6 +13,10 @@ public interface IPreplanPictureDao extends BaseDao<PreplanPicture, Long> { ...@@ -11,6 +13,10 @@ public interface IPreplanPictureDao extends BaseDao<PreplanPicture, Long> {
@Query(value = "select * from f_preplan_picture where equipment_id=?1 and type = ?2", nativeQuery = true) @Query(value = "select * from f_preplan_picture where equipment_id=?1 and type = ?2", nativeQuery = true)
PreplanPicture selectOne(Long id, int type); PreplanPicture selectOne(Long id, int type);
@Transactional
@Modifying
@Query(value = "delete from f_preplan_picture where equipment_id=?1", nativeQuery = true)
int deletebyEqId(Long id);
List<PreplanPicture> findByEquipmentId(Long equipmentId); List<PreplanPicture> findByEquipmentId(Long equipmentId);
......
...@@ -85,6 +85,9 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -85,6 +85,9 @@ public class EquipmentServiceImpl implements IEquipmentService {
@Value("${linux.img.path}") @Value("${linux.img.path}")
private String linuxImgPath; private String linuxImgPath;
@Value("${server.servlet.context-path}")
private String fireAutoSys;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
...@@ -331,6 +334,19 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -331,6 +334,19 @@ public class EquipmentServiceImpl implements IEquipmentService {
@Override @Override
public Equipment saveEquipmentAndImg(ImgParam[] imgs, Equipment equipment) { public Equipment saveEquipmentAndImg(ImgParam[] imgs, Equipment equipment) {
String path = FasConstant.UPLOAD_ROOT_PATH + File.separator + FasConstant.UPLOAD_EQUIPMENT_PATH
+ File.separator + equipment.getId();
String filePath = getRootPath() + path;
preplanPictureDao.deletebyEqId(equipment.getId());
File file1 = new File(filePath);
if (file1.exists()){
File[] files = file1.listFiles();
if (files.length >0){
for (File f: files) {
f.delete();
}
}
}
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (imgs == null || imgs.length < 1) { if (imgs == null || imgs.length < 1) {
equipment = save(equipment); equipment = save(equipment);
...@@ -369,9 +385,6 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -369,9 +385,6 @@ public class EquipmentServiceImpl implements IEquipmentService {
pp.setCreateDate(new Date()); pp.setCreateDate(new Date());
} }
String path = FasConstant.UPLOAD_ROOT_PATH + File.separator + FasConstant.UPLOAD_EQUIPMENT_PATH
+ File.separator + equipment.getId();
String filePath = getRootPath() + path;
String fileType = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."), String fileType = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."),
file.getOriginalFilename().length()); file.getOriginalFilename().length());
...@@ -390,7 +403,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -390,7 +403,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
throw new YeeException("上传图片失败"); throw new YeeException("上传图片失败");
} }
String picture = path + fileName; String picture = fireAutoSys+"/"+path + fileName;
pp.setPicture(picture); pp.setPicture(picture);
preplanPictureDao.saveAndFlush(pp); preplanPictureDao.saveAndFlush(pp);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment