|
@@ -526,10 +526,22 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public byte[] downloadFile(MaterialTaskAssignListDto dto) {
|
|
public byte[] downloadFile(MaterialTaskAssignListDto dto) {
|
|
- List<MaterialTaskAppendix> appendices = appendixMapper.selectList(
|
|
|
|
- new QueryWrapper<MaterialTaskAppendix>().lambda()
|
|
|
|
- .eq(MaterialTaskAppendix::getMaterialTaskId, dto.getMaterialTaskId())
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
|
|
+ MPJLambdaWrapper<MaterialTaskAppendix> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
|
+ queryWrapper
|
|
|
|
+ .disableSubLogicDel()
|
|
|
|
+ .distinct()
|
|
|
|
+ .select(MaterialTaskAppendix::getId)
|
|
|
|
+ .select(MaterialTaskAppendix.class, x -> VoToColumnUtil.fieldsToColumns(MaterialTaskAppendix.class).contains(x.getProperty()))
|
|
|
|
+ .innerJoin(MaterialTaskAssign.class, MaterialTaskAssign::getId, MaterialTaskAppendix::getMaterialTaskId)
|
|
|
|
+ .eq(MaterialTaskAssign::getMaterialTaskId, dto.getMaterialTaskId())
|
|
|
|
+ .eq(MaterialTaskAssign::getStatus, dto.getState())
|
|
|
|
+ ;
|
|
|
|
+
|
|
|
|
+ List<MaterialTaskAppendix> appendices = appendixMapper.selectJoinList(MaterialTaskAppendix.class, queryWrapper);
|
|
|
|
+ if(appendices.isEmpty()){
|
|
|
|
+ throw new MyException("未能查询到附件");
|
|
|
|
+ }
|
|
List<Long> userIds = appendices.stream().map(MaterialTaskAppendix::getCreateUserId).collect(Collectors.toList());
|
|
List<Long> userIds = appendices.stream().map(MaterialTaskAppendix::getCreateUserId).collect(Collectors.toList());
|
|
List<User> userList = userService.listByIds(userIds);
|
|
List<User> userList = userService.listByIds(userIds);
|
|
Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, x -> x));
|
|
Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, x -> x));
|
|
@@ -538,8 +550,9 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
MaterialTask task = this.getById(dto.getMaterialTaskId());
|
|
MaterialTask task = this.getById(dto.getMaterialTaskId());
|
|
|
|
|
|
for (MaterialTaskAppendix appendix : appendices) {
|
|
for (MaterialTaskAppendix appendix : appendices) {
|
|
- List<File> fileList = fileService.list(Wrappers.<File>query().lambda().eq(File::getFolderId, appendix.getFileId()));
|
|
|
|
|
|
+ List<File> fileList = fileService.list(Wrappers.<File>query().lambda().eq(File::getId, appendix.getFileId()));
|
|
User user = userMap.get(appendix.getCreateUserId());
|
|
User user = userMap.get(appendix.getCreateUserId());
|
|
|
|
+
|
|
for (int i = 0; i < fileList.size(); i++) {
|
|
for (int i = 0; i < fileList.size(); i++) {
|
|
try {
|
|
try {
|
|
URL url = new URL(fileList.get(i).getFileUrl());
|
|
URL url = new URL(fileList.get(i).getFileUrl());
|
|
@@ -552,7 +565,12 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
outputStream.write(buffer, 0, bytesRead);
|
|
outputStream.write(buffer, 0, bytesRead);
|
|
}
|
|
}
|
|
byte[] byteArray = outputStream.toByteArray();
|
|
byte[] byteArray = outputStream.toByteArray();
|
|
- byteAryMap.put(user.getName() + "-" + user.getUserName() + "-" + task.getName() + fileList.get(i).getFileType(), byteArray);
|
|
|
|
|
|
+ String fileName = user.getName() + "-" + user.getUserName() + "-" + task.getName();
|
|
|
|
+ if(fileList.size() > 1){
|
|
|
|
+ fileName += "-" + (i + 1);
|
|
|
|
+ }
|
|
|
|
+ fileName += fileList.get(i).getFileType();
|
|
|
|
+ byteAryMap.put(fileName, byteArray);
|
|
in.close();
|
|
in.close();
|
|
outputStream.close();
|
|
outputStream.close();
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|