|
@@ -16,6 +16,7 @@ import net.lingala.zip4j.core.ZipFile;
|
|
|
import net.lingala.zip4j.model.ZipParameters;
|
|
|
import net.lingala.zip4j.util.Zip4jConstants;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -69,6 +70,10 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
NewsNoticeMapper newsNoticeMapper;
|
|
|
@Resource
|
|
|
NewsNoticeUserMapper newsNoticeUserMapper;
|
|
|
+ @Autowired
|
|
|
+ private OpenOfficeService openOfficeService;
|
|
|
+ @Resource
|
|
|
+ PdfFileMapper pdfFileMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -112,7 +117,12 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
e.printStackTrace();
|
|
|
projectFile = null;
|
|
|
}
|
|
|
+ //上传完,需要生成pdf
|
|
|
+ String dFile1 = path+UUID.randomUUID().toString().replaceAll("-", "")+".pdf";
|
|
|
+ openOfficeService.start();
|
|
|
+ openOfficeService.office2PDF(path + fileName,dFile1);
|
|
|
//模具报废情况下,设置files2
|
|
|
+ String dFile2 = "";
|
|
|
if (blongType == 5 && file2 != null && !file2.isEmpty()) {
|
|
|
String fileName2 = file2.getOriginalFilename();
|
|
|
projectFile.setFileName2(fileName2);
|
|
@@ -128,6 +138,8 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
try {
|
|
|
saveFile2.createNewFile();
|
|
|
file2.transferTo(saveFile2);
|
|
|
+ dFile2 = path+UUID.randomUUID().toString().replaceAll("-", "")+".pdf";
|
|
|
+ openOfficeService.office2PDF(path + fileName,dFile2);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
projectFile = null;
|
|
@@ -136,6 +148,8 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
projectFile = null;
|
|
|
}
|
|
|
}
|
|
|
+ //关闭openOffice
|
|
|
+ openOfficeService.shutdown();
|
|
|
//零件文档时存上零件id
|
|
|
if (blongType == 1 && null != userVO.getPartId()) {
|
|
|
projectFile.setPartId(userVO.getPartId());
|
|
@@ -145,6 +159,22 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
projectFile.setDwgType(userVO.getDwgType());
|
|
|
}
|
|
|
mouldFileMapper.insert(projectFile);
|
|
|
+ PdfFile pdfFile = new PdfFile();
|
|
|
+ pdfFile.setPdfUrl("/upload/"+dFile1);
|
|
|
+ pdfFile.setFileId(projectFile.getId());
|
|
|
+ pdfFile.setType(0);
|
|
|
+ pdfFile.setRafId(projectFile.getModelId());
|
|
|
+ pdfFile.setSourceFileUrl(projectFile.getFileUrl());
|
|
|
+ pdfFileMapper.insert(pdfFile);
|
|
|
+ if(blongType == 5 && file2 != null && !file2.isEmpty()){
|
|
|
+ pdfFile = new PdfFile();
|
|
|
+ pdfFile.setPdfUrl("/upload/"+dFile2);
|
|
|
+ pdfFile.setFileId(projectFile.getId());
|
|
|
+ pdfFile.setType(0);
|
|
|
+ pdfFile.setRafId(projectFile.getModelId());
|
|
|
+ pdfFile.setSourceFileUrl(projectFile.getFileUrl2());
|
|
|
+ pdfFileMapper.insert(pdfFile);
|
|
|
+ }
|
|
|
Project project = projectMapper.selectById(mould.getProjectId());
|
|
|
Integer count = projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", user.getId()).eq("project_id", project.getId()));
|
|
|
// if(count>0){
|
|
@@ -645,6 +675,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
|
|
|
if (user != null) {
|
|
|
List<Part> partLists = partMapper.selectList(new QueryWrapper<Part>().eq("mould_id", userVO.getMouldId()));
|
|
|
+ openOfficeService.start();
|
|
|
for (MultipartFile file : files) {
|
|
|
MouldFile partFile = new MouldFile();
|
|
|
partFile.setModelId(userVO.getMouldId());
|
|
@@ -697,6 +728,16 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
try {
|
|
|
saveFile.createNewFile();
|
|
|
file.transferTo(saveFile);
|
|
|
+ //上传完,需要生成pdf
|
|
|
+ String dFile1 = path+UUID.randomUUID().toString().replaceAll("-", "")+".pdf";
|
|
|
+ openOfficeService.office2PDF(path + fileName,dFile1);
|
|
|
+ PdfFile pdfFile = new PdfFile();
|
|
|
+ pdfFile.setPdfUrl("/upload/"+dFile1);
|
|
|
+ pdfFile.setFileId(partFile.getId());
|
|
|
+ pdfFile.setType(1);
|
|
|
+ pdfFile.setRafId(partFile.getModelId());
|
|
|
+ pdfFile.setSourceFileUrl(partFile.getFileUrl());
|
|
|
+ pdfFileMapper.insert(pdfFile);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
partFile = null;
|
|
@@ -733,6 +774,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
|
|
|
// }
|
|
|
msg.data = partFile;
|
|
|
}
|
|
|
+ openOfficeService.shutdown();
|
|
|
} else {
|
|
|
msg.setError("用户不存在或者未登录");
|
|
|
}
|