|
|
@ -1,15 +1,24 @@
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.entity.*;
|
|
|
|
import com.shxy.xymanager_common.entity.*;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.util.DateUtil;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.util.DigestUtils;
|
|
|
|
import com.shxy.xymanager_dao.dao.MntnUploadsMapper;
|
|
|
|
import com.shxy.xymanager_dao.dao.MntnUploadsMapper;
|
|
|
|
import com.shxy.xymanager_service.service.MntnUploadService;
|
|
|
|
import com.shxy.xymanager_service.service.MntnUploadService;
|
|
|
|
import com.shxy.xymanager_service.service.NewCacheService;
|
|
|
|
import com.shxy.xymanager_service.service.NewCacheService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -17,6 +26,9 @@ import java.util.List;
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public class MntnUploadServiceImpl implements MntnUploadService {
|
|
|
|
public class MntnUploadServiceImpl implements MntnUploadService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${maintain.termlog}")
|
|
|
|
|
|
|
|
private String termlog;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
MntnUploadsMapper mapper;
|
|
|
|
MntnUploadsMapper mapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -50,4 +62,25 @@ public class MntnUploadServiceImpl implements MntnUploadService {
|
|
|
|
mapper.deleteByPrimaryKey(id);
|
|
|
|
mapper.deleteByPrimaryKey(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void uploadLog(Integer termId, MultipartFile file) throws Exception {
|
|
|
|
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
|
|
|
|
|
String ext = StringUtils.getFilenameExtension(fileName);
|
|
|
|
|
|
|
|
String path = DateUtil.format(new Date(), "yyyyMMdd") + "_log_"
|
|
|
|
|
|
|
|
+ UUID.randomUUID().toString().replace("-", "").substring(0, 13);
|
|
|
|
|
|
|
|
if (StringUtils.hasLength(ext)) {
|
|
|
|
|
|
|
|
path = path + "." + ext;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MntnUploads item = new MntnUploads();
|
|
|
|
|
|
|
|
item.setTermId(termId);
|
|
|
|
|
|
|
|
item.setFileName(fileName);
|
|
|
|
|
|
|
|
item.setPath(path);
|
|
|
|
|
|
|
|
item.setFileSize((int) file.getSize());
|
|
|
|
|
|
|
|
item.setCreateTime(new Date());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File dest = new File(termlog + path);
|
|
|
|
|
|
|
|
file.transferTo(dest);
|
|
|
|
|
|
|
|
mapper.insert(item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|