|
@@ -6,6 +6,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
@@ -15,6 +16,7 @@ import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.MaterialCategoryEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.model.generator.ComponentConfig;
|
|
|
+import com.xjrsoft.common.utils.FileZipUtil;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.concat.service.IXjrUserService;
|
|
@@ -50,6 +52,8 @@ import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.organization.service.IWeChatService;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
+import com.xjrsoft.module.system.entity.File;
|
|
|
+import com.xjrsoft.module.system.service.IFileService;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.teacher.vo.XjrUserVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -57,6 +61,10 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLConnection;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
@@ -74,7 +82,7 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
private final MaterialTaskMapper materialTaskMaterialTaskMapper;
|
|
|
|
|
|
private final MaterialTaskAssignMapper materialTaskMaterialTaskAssignMapper;
|
|
|
- private final MaterialTaskAppendixMapper materialTaskMaterialTaskAppendixMapper;
|
|
|
+ private final MaterialTaskAppendixMapper appendixMapper;
|
|
|
|
|
|
private final IMaterialTypeService materialTypeService;
|
|
|
private final IWeChatService weChatService;
|
|
@@ -82,6 +90,8 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
private final IFormExecuteService formExecuteService;
|
|
|
|
|
|
private final FormTemplateMapper formTemplateMapper;
|
|
|
+ private final IFileService fileService;
|
|
|
+ private final IUserService userService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -219,7 +229,7 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
//********************************* MaterialTaskAppendix 增删改 开始 *******************************************/
|
|
|
{
|
|
|
// 查出所有子级的id
|
|
|
- List<MaterialTaskAppendix> materialTaskAppendixList = materialTaskMaterialTaskAppendixMapper.selectList(Wrappers.lambdaQuery(MaterialTaskAppendix.class).eq(MaterialTaskAppendix::getMaterialTaskId, materialTask.getId()).select(MaterialTaskAppendix::getId));
|
|
|
+ List<MaterialTaskAppendix> materialTaskAppendixList = appendixMapper.selectList(Wrappers.lambdaQuery(MaterialTaskAppendix.class).eq(MaterialTaskAppendix::getMaterialTaskId, materialTask.getId()).select(MaterialTaskAppendix::getId));
|
|
|
List<Long> materialTaskAppendixIds = materialTaskAppendixList.stream().map(MaterialTaskAppendix::getId).collect(Collectors.toList());
|
|
|
//原有子表单 没有被删除的主键
|
|
|
List<Long> materialTaskAppendixOldIds = materialTask.getMaterialTaskAppendixList().stream().map(MaterialTaskAppendix::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
@@ -229,18 +239,18 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
for (MaterialTaskAppendix materialTaskAppendix : materialTask.getMaterialTaskAppendixList()) {
|
|
|
//如果不等于空则修改
|
|
|
if (materialTaskAppendix.getId() != null) {
|
|
|
- materialTaskMaterialTaskAppendixMapper.updateById(materialTaskAppendix);
|
|
|
+ appendixMapper.updateById(materialTaskAppendix);
|
|
|
}
|
|
|
//如果等于空 则新增
|
|
|
else {
|
|
|
//已经不存在的id 删除
|
|
|
materialTaskAppendix.setMaterialTaskId(materialTask.getId());
|
|
|
- materialTaskMaterialTaskAppendixMapper.insert(materialTaskAppendix);
|
|
|
+ appendixMapper.insert(materialTaskAppendix);
|
|
|
}
|
|
|
}
|
|
|
//已经不存在的id 删除
|
|
|
if (materialTaskAppendixRemoveIds.size() > 0) {
|
|
|
- materialTaskMaterialTaskAppendixMapper.deleteBatchIds(materialTaskAppendixRemoveIds);
|
|
|
+ appendixMapper.deleteBatchIds(materialTaskAppendixRemoveIds);
|
|
|
}
|
|
|
}
|
|
|
//********************************* MaterialTaskAppendix 增删改 结束 *******************************************/
|
|
@@ -253,7 +263,7 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
public Boolean delete(List<Long> ids) {
|
|
|
materialTaskMaterialTaskMapper.deleteBatchIds(ids);
|
|
|
materialTaskMaterialTaskAssignMapper.delete(Wrappers.lambdaQuery(MaterialTaskAssign.class).in(MaterialTaskAssign::getMaterialTaskId, ids));
|
|
|
- materialTaskMaterialTaskAppendixMapper.delete(Wrappers.lambdaQuery(MaterialTaskAppendix.class).in(MaterialTaskAppendix::getMaterialTaskId, ids));
|
|
|
+ appendixMapper.delete(Wrappers.lambdaQuery(MaterialTaskAppendix.class).in(MaterialTaskAppendix::getMaterialTaskId, ids));
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -289,14 +299,14 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
materialTaskMaterialTaskAssignMapper.updateById(materialTaskAssign);
|
|
|
|
|
|
if (oldStatus == 4) { // 重做删除原来的
|
|
|
- materialTaskMaterialTaskAppendixMapper.delete(Wrappers.lambdaQuery(MaterialTaskAppendix.class).eq(MaterialTaskAppendix::getMaterialTaskId, materialTaskAssignAppendixDto.getMaterialTaskAssignId()));
|
|
|
+ appendixMapper.delete(Wrappers.lambdaQuery(MaterialTaskAppendix.class).eq(MaterialTaskAppendix::getMaterialTaskId, materialTaskAssignAppendixDto.getMaterialTaskAssignId()));
|
|
|
}
|
|
|
|
|
|
for (AddMaterialTaskAppendixDto materialTaskAppendixDto : materialTaskAssignAppendixDto.getMaterialTaskAppendixList()) {
|
|
|
MaterialTaskAppendix materialTaskAppendix = new MaterialTaskAppendix();
|
|
|
materialTaskAppendix.setMaterialTaskId(materialTaskAssignAppendixDto.getMaterialTaskAssignId());
|
|
|
materialTaskAppendix.setFileId(materialTaskAppendixDto.getFileId());
|
|
|
- materialTaskMaterialTaskAppendixMapper.insert(materialTaskAppendix);
|
|
|
+ appendixMapper.insert(materialTaskAppendix);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -329,7 +339,7 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
materialTaskMaterialTaskAssignMapper.updateById(materialTaskAssign);
|
|
|
|
|
|
if (oldStatus == 4) { // 重做删除原来的
|
|
|
- materialTaskMaterialTaskAppendixMapper.delete(Wrappers.lambdaQuery(MaterialTaskAppendix.class).eq(MaterialTaskAppendix::getMaterialTaskId, materialTaskAssignAppendixDto.getMaterialTaskAssignId()));
|
|
|
+ appendixMapper.delete(Wrappers.lambdaQuery(MaterialTaskAppendix.class).eq(MaterialTaskAppendix::getMaterialTaskId, materialTaskAssignAppendixDto.getMaterialTaskAssignId()));
|
|
|
}
|
|
|
|
|
|
long id = formExecuteService.addByTemplateId(new FormExecuteAddOrUpdateDto(){{
|
|
@@ -340,7 +350,7 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
MaterialTaskAppendix materialTaskAppendix = new MaterialTaskAppendix();
|
|
|
materialTaskAppendix.setMaterialTaskId(materialTaskAssignAppendixDto.getMaterialTaskAssignId());
|
|
|
materialTaskAppendix.setFileId(id);
|
|
|
- materialTaskMaterialTaskAppendixMapper.insert(materialTaskAppendix);
|
|
|
+ appendixMapper.insert(materialTaskAppendix);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -466,8 +476,11 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
|
|
|
List<MaterialTaskAssignListVo> pageOutput = materialTaskMaterialTaskAssignMapper.selectJoinList(MaterialTaskAssignListVo.class, queryWrapper);
|
|
|
|
|
|
- for (MaterialTaskAssignListVo materialTaskAssignListVo : pageOutput){
|
|
|
- materialTypeService.handleFileAndTemplate(materialTaskAssignListVo, materialTaskAssignListVo.getMaterialCategory());
|
|
|
+ for (MaterialTaskAssignListVo el : pageOutput){
|
|
|
+ materialTypeService.handleFileAndTemplate(el, el.getMaterialCategory());
|
|
|
+
|
|
|
+ List<File> fileList = fileService.list(Wrappers.<File>query().lambda().eq(File::getFolderId, el.getFolderId()));
|
|
|
+ el.setFiles(fileList);
|
|
|
}
|
|
|
|
|
|
return pageOutput;
|
|
@@ -509,6 +522,46 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public byte[] downloadFile(MaterialTaskAssignListDto dto) {
|
|
|
+ List<MaterialTaskAppendix> appendices = appendixMapper.selectList(
|
|
|
+ new QueryWrapper<MaterialTaskAppendix>().lambda()
|
|
|
+ .eq(MaterialTaskAppendix::getMaterialTaskId, dto.getMaterialTaskId())
|
|
|
+ );
|
|
|
+ List<Long> userIds = appendices.stream().map(MaterialTaskAppendix::getCreateUserId).collect(Collectors.toList());
|
|
|
+ List<User> userList = userService.listByIds(userIds);
|
|
|
+ Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, x -> x));
|
|
|
+
|
|
|
+ Map<String, byte[]> byteAryMap = new HashMap<>();
|
|
|
+ MaterialTask task = this.getById(dto.getMaterialTaskId());
|
|
|
+
|
|
|
+ for (MaterialTaskAppendix appendix : appendices) {
|
|
|
+ List<File> fileList = fileService.list(Wrappers.<File>query().lambda().eq(File::getFolderId, appendix.getFileId()));
|
|
|
+ User user = userMap.get(appendix.getCreateUserId());
|
|
|
+ for (int i = 0; i < fileList.size(); i++) {
|
|
|
+ try {
|
|
|
+ URL url = new URL(fileList.get(i).getFileUrl());
|
|
|
+ URLConnection conn = url.openConnection();
|
|
|
+ InputStream in = conn.getInputStream();
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int bytesRead;
|
|
|
+ while ((bytesRead = in.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ byte[] byteArray = outputStream.toByteArray();
|
|
|
+ byteAryMap.put(user.getName() + "-" + user.getUserName() + "-" + task.getName() + fileList.get(i).getFileType(), byteArray);
|
|
|
+ in.close();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new MyException("文件下载失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return FileZipUtil.byteAryMap2Zip(byteAryMap);
|
|
|
+ }
|
|
|
+
|
|
|
private void sendMessageUtil(MaterialTask materialTask ) {
|
|
|
IUserService userService = SpringUtil.getBean(IUserService.class);
|
|
|
RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
|